hola logre realizar los cambios despues de probarla por un dia me ayudaste mucho, en el modo multi curso tienes un detalle un input en el scraper en la linea 242 en el metodo scrape_course(), que hace que tengas que dar enter para seguir al siguiente curso de la lista, no estoy si afecta en el algo si lo hace por favor me lo mencionas, pero lo elimine, y ahora va fluido.
creo que esa linea iria perfecto al final del metodo scrape_courses al finalizar la lista de todos los cursos realice la pausa
def scrape_course(numeration, r_object, course_url):
data = {}
tools.clear_screen()
target_page = html.fromstring(r_object.content)
course_title = style.format_name_string(
target_page.xpath('//h1[@class="CourseDetail-left-title"]/text()')[0]
)
if mode == 2:
course_title = f"{numeration} - {course_title}"
em = style.format_string(f" Processing: {course_title}", 16)
header(" downloading", em, "cyan", "left", 1, "-", "green", 0)
print(style.string_color(" Course information: \n", "blue"))
sleep(style.line_sleep)
print(style.format_string(f" Course: {course_title}", 12))
# Download course page
helper.download_page(course_url, course_title, "000 - Preview.html")
course_url = course_url.replace("/clases/", "/cursos/")
helper.download_page(course_url, course_title, "Course Details.html")
sections = target_page.xpath('//div[@class="Material-concept"]')
s_count = 1
l_count = 1
for s in sections:
sn = "00"
if s_count > 9:
sn = "0"
s_title = s.xpath(
'div[@class="Material-concept-edit"]'
'/h3[@class="Material-title"]/text()')[0]
s_title = f"{sn}{s_count} - {style.format_name_string(s_title)}"
# print()
# p_print.line_char("-", "cyan", 2)
# print(style.format_string(f" Section: {s_title}\n", 13))
for lesson in s.xpath('div[@class="MaterialItem-content"]'):
ln = "00"
if l_count > 9:
ln = "0"
lock_element = 'div/div[@class="MaterialItem-copy"]' \
'/div[@class="MaterialItem-copy-actions"]/div[' \
'@class="MaterialItem-copy-actions-anchor"]/i/@class '
if not len(lesson.xpath(lock_element)) > 0:
if len(lesson.xpath('div/div[@class="MaterialItem-video"]')) > 0:
# lesson_type = "[VIDEO_NAME]"
# course_data["type"] = "video"
l_type = "video"
else:
# lesson_type = "[MATERIAL_NAME]"
# course_data["type"] = "material"
l_type = "material"
l_title = lesson.xpath('div/div[@class="MaterialItem-copy"]'
'/p[@class="MaterialItem-copy-title"]'
'/text()')
l_title = f"{ln}{l_count} - {style.format_name_string(l_title[0])}"
# print(style.format_string(f" Lesson: {l_title}", 14))
l_url = lesson.xpath('a[@class="MaterialItem-anchor"]'
'/@href')[0]
l_url = url_tool.base_url + l_url
# print(style.format_string(f" URL: {l_url}", 13))
# set data and start lesson download action
data["path"] = course_title + '/' + s_title
data["name"] = l_title
data["url"] = l_url
data["type"] = l_type
if l_type == "video":
data["extra_path"] = f"{course_title}/{s_title}/"
data["extra_path"] += f"{ln}{l_count} - extra_files"
data["webpage"] = f"{ln}{l_count} - webpage.html"
helper.download_lesson(data)
tools.clear_screen()
l_count += 1
s_count += 1
input("\n\n Press enter to continue")