packt-cli / Packt-Publishing-Free-Learning

Scripts that automatically claim and download free daily eBooks from https://www.packtpub.com/packt/offers/free-learning
MIT License
858 stars 185 forks source link

"'NoneType' object has no attribute 'attrs'" error when activating some books #115

Closed SR-G closed 5 years ago

SR-G commented 5 years ago

I have from time to time this error :

Today's free Packt ebook grabbing has failed with exception: 'NoneType' object has no attribute 'attrs'!

Logs :

[INFO] - Creating session...
[INFO] - Session created, logged in successfully!
[INFO] - Start grabbing eBook...
[INFO] - Captcha detected. Trying to solve it using anti-captcha.com.
[INFO] - TaskId created: 67762126
[INFO] - Waiting for completion of the task: 67762126...
[SUCCESS] - Solution found for task: 67762126
[SUCCESS] - eBook: '****************' has been successfully grabbed!
[INFO] - Retrieving complete information for '****************
[ERROR] - Exception occurred 'NoneType' object has no attribute 'attrs'
[INFO] - Sending email from **************** to **************** ...
[INFO] - Email to **************** has been succesfully sent

In the packt website > account > My Ebooks >the corresponding book seems to be correctly grabbed this day.

mjenczmyk commented 5 years ago

Thanks for submitting this error! Personally I don't use -l parameter so I've never seen this (the script lacks testing though).

OK, I see - it succeeded in grabbing the ebook, but failed on fetching ebook's data. It couldn't find URL for downloading code files, because there are none, so there is no <a> inside button (which is disabled). Did it happen with "Mastering Windows PowerShell Scripting - Second Edition" today? Did other books with which the script failed in this way also didn't have code files?

SR-G commented 5 years ago

I'm only using it this script since ten days. It has failed two times for now :

Indeed it seems both of these books don't have any code attached to them.

mjenczmyk commented 5 years ago

OK, the problem is that script tries to find code files URL even if it doesn't exist. Do you want to make a pull request or should I?

mjenczmyk commented 5 years ago

https://github.com/igbt6/Packt-Publishing-Free-Learning/pull/117 Here is a fix for this issue.

luk6xff commented 5 years ago

Fixed at #117