Python Forum
The free book for the day from - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: The free book for the day from (/thread-4677.html)

Pages: 1 2


The free book for the day from - wavic - Sep-02-2017

I am lazy man so it's too much for me to open a browser and check for the today free offer from packtpub.com
Here is a little script to tell me just thas. Eventually I could put some notification and asign a shortcut key combination to run it. I love Linux :)

from selenium import webdriver
from bs4 import BeautifulSoup


url = "https://www.packtpub.com/packt/offers/free-learning"

driver = webdriver.PhantomJS()
driver.get(url)
html = driver.page_source

soup = BeautifulSoup(html, "lxml")

expire_time = soup.find('span', class_='packt-js-countdown').text.strip()
book_title = soup.find('h2').text.strip()

print('The free book for today from https://www.packtpub.com is')
print('"{}"'.format(book_title))
print('Expire in: {}'.format(expire_time))



RE: The free book for the day from - metulburr - Sep-02-2017

i didnt know about this website. Do they always give away free programming books. We could add this to our Yoriz free books thread or something.

EDIT:
oh nevermind. Its a 30 day trail to get it for free


RE: The free book for the day from - wavic - Sep-02-2017

We already have it as a topic here:
https://python-forum.io/Thread-book-Various-python-and-non-python-books-available-each-day-free-for-24hrs

Also, I have a registration there from a long time and can download every book they offer for free from the link in the script. I don't know what is that 30 days trail you are talking about


RE: The free book for the day from - snippsat - Sep-02-2017

Good work.
(Sep-02-2017, 12:37 PM)wavic Wrote: I love Linux :)
It work on Windows to,if you wonder Wink

The free books are free,no trial.
I do forget these offer all time,and will of course forget to run a script like this to.

It could be and idea to make it all automatic.
Then have to write login/password to site and then click() Claim Your Free eBook .
Then pass this code to job scheduling,my favorite in Python Job scheduling for humans.
Or use OS scheduling.


RE: The free book for the day from - wavic - Sep-02-2017

It'd be good but there is reCAPTCHA to identify that you are not a bot


RE: The free book for the day from - wavic - Sep-02-2017

As selenium is something I have never used before I found that there is no need of BeautifulSoup in this particular case.

from selenium import webdriver


url = "https://www.packtpub.com/packt/offers/free-learning"

driver = webdriver.PhantomJS()
driver.get(url)
book_title = driver.find_element_by_tag_name('h2').text
expire_time = driver.find_element_by_class_name('packt-js-countdown').text

print('The free book for today from https://www.packtpub.com is')
print('"{}"'.format(book_title))
print('Expire in: {}'.format(expire_time))



RE: The free book for the day from - metulburr - Sep-02-2017

shows how much i pay attention Doh

You could run it auto on this server, then change the post content via mysql to update the OP of that thread to the current book that is for free. Not that that it is going to claim the book for anyone automatically.


RE: The free book for the day from - Larz60+ - Sep-02-2017

Don't forget O'Reilly's free book site: http://www.oreilly.com/programming/free/


RE: The free book for the day from - wavic - Sep-02-2017

(Sep-02-2017, 10:36 PM)metulburr Wrote: shows how much i pay attention Doh

You could run it auto on this server, then change the post content via mysql to update the OP of that thread to the current book that is for free. Not that that it is going to claim the book for anyone automatically.

If I have time I will do it. Probably. Good idea Smile


RE: The free book for the day from - metulburr - Sep-03-2017

Does it consistently change to a new book every 12 hours or something?