edx-downloader
edx-downloader copied to clipboard
KeyError: u'href
Hi, I kept encountering the following KeyError when running then standalone windows version. Not sure what's wrong there?
Traceback (most recent call last):
File "
.
same problem
@kevw22 @Hasset Sorry for the late reply. Could you tell me which course? I can't replicate this problem.
Hi @coiby , the error encountered in initiation.
@Hasset Thank you!
According to the info you provide, there's something wrong with parsing out article[class='course']
. Normally, COURSE
should look like this:
<article class="course honor">
<section class="details">
<div aria-hidden="true" class="wrapper-course-image">
<a class="cover" href="/courses/McGillX/Body101x/1T2015/info">
<img alt="Body101x The Body Matters Home Page" class="course-image" src="/c4x/McGillX/Body101x/asset/Body101x_thumbnail.jpeg"/>
</a>
...
</div>
</section>
...
</article>
Could you print the content in COURSE
?
for COURSE in COURSES:
c_name = COURSE.h3.text.strip()
print(COURSE) #add this before line 417
c_link = BASE_URL + COURSE.a['href']
if c_link.endswith('info') or c_link.endswith('info/'):
state = 'Started'
else:
state = 'Not yet'
courses.append((c_name, c_link, state))
numOfCourses = len(courses)
Hi @coiby ,
@Hasset I'm sorry, but what I mean is that you add debugging code and run the program again to print COURSE
.
Hi @coiby , I don't know how to run the debugging code.
Hi @coiby , I got it.
@Hasset Thanks for your feedback. I've confirmed this bug. It's because there's no hyperlink, i.e., no href attribute for some courses which haven't started yet. A temporarily solution is to unenroll out of that kind of courses. But I'll fix this bug before tomorrow night.
@coiby That's a very good news! Hurry up! :D
@Hasset I've adopted a solution from iemejia/edx-downloader. But only edx-dl.py has been updated. Standalone packages will be updated a few days later.
@coiby I've tested. It runs smoothly. Thanks!