Scripts that automatically claim and download free daily eBooks from https://www.packtpub.com/packt/offers/free-learning
packt-cli
is a Python script that allows to automatically grab and download a daily Free
Learning Packt ebook from https://www.packtpub.com/packt/offers/free-learning.
You can also use it to download already claimed ebooks from your Packt
account.
The script uses anti-captcha.com service to bypass the Recaptcha captcha to function fully automatically. Anti Captcha employs people to solve captcha tests. The service costs about $2 per thousand captcha test, allowing you to operate for a few dollars over the years.
To install current version of script simply run
pip3 install packt --upgrade
You may want to install it inside new virtualenv.
The packt-cli
script might be executed with several optional arguments.
packt-cli -g
packt-cli -gd
packt-cli -da
packt-cli -sgd
packt-cli -m
packt-cli -gd -sm
packt-cli -gd -f
packt-cli -gd -c /home/usr/
Download all ebooks in all available formats (pdf, epub, mobi) with zipped source code file from your Packt account.
To download all ebooks in all available formats from your Packt account, you have to prepare your config file as shown below:
[LOGIN_DATA]
email: [email protected]
password: yourpassword
[DOWNLOAD_DATA]
download_folder_path: C:\Users\me\Desktop\myEbooksFromPackt
download_formats: pdf, epub, mobi, code
[GOOGLE_DRIVE_DATA]
gd_app_name: GoogleDriveManager
gd_folder_name: PACKT_EBOOKS
run:
packt-cli -da
On Debian (and any Debian-based Linux distribution) you may use cron job to schedule script execution. To do this run crontab -e
and add the following line to crontab file.
0 12 * * * path/to/virtualenv/bin/packt-cli -gd > path/to/log/file 2>&1
Adjust execution time and paths according to your setup. To verify if cron executes the script as expected, run
$ sudo grep CRON /var/log/syslog
schtasks.exe setup (more info: https://technet.microsoft.com/en-us/library/cc725744.aspx) :
To create the task that will be called at 12:00 everyday, run the following command in cmd (modify all paths according to your setup):
schtasks /create /sc DAILY /tn "grabEbookFromPacktTask" /tr "C:\Users\me\Desktop\GrabPacktFreeBook\grabEbookFromPacktTask.bat" /st 12:00
To check if the "grabEbookFromPacktTask" has been added to all scheduled tasks on your computer:
schtasks /query
To run the task manually:
schtasks /run /tn "grabEbookFromPacktTask"
To delete the task:
schtasks /delete /tn "grabEbookFromPacktTask"
If you want to log all downloads add -l switch to grabEbookFromPacktTask i.e.
schtasks /create /sc DAILY /tn "grabEbookFromPacktTask" /tr "C:\Users\me\Desktop\GrabPacktFreeBook\grabEbookFromPacktTask.bat -l" /st 12:00
If you want to additionaly make command line windows stay open after download add -p switch i.e.
schtasks /create /sc DAILY /tn "grabEbookFromPacktTask" /tr "C:\Users\me\Desktop\GrabPacktFreeBook\grabEbookFromPacktTask.bat -l -p" /st 12:00
Full info about the Google Drive Python API can be found here.
Continue
, then Go to credentials
.Add credentials to your project page
, click the Cancel
button.OAuth consent screen
tab. Select an email address, enter a product name if not already set, and click the Save button.Credentials
tab, click the Create credentials
button and select OAuth client ID
.Other
, enter the name GoogleDriveManager
, and click the Create
button.OK
to dismiss the resulting dialog.Download JSON
) button to the right of the client ID.client_secret.json
.-sgd
argument; During first launch you will see a prompt in your browser asking for permissions, click then allow
packt-cli -sgd
--noauth_local_webserver
).packt-cli -c /path/to/config/file.cfg -sgd --noauth_local_webserver
The command parameters number and their order is important!
In case of any questions feel free to ask, happy grabbing!