Automate the boring stuff!

Isn’t it a manual task to visit a website every day to view your favorite comic strip? Why not let a script do it for you? And maybe send it as an email attachment at a specified time every day of the week! Well, with the help of Python book, ‘Automate the Boring Stuff’ let’s create our small script to download and send that as an email attachment.


I have created download_xkcd.py which scrapes https://xkcd.com for a comic and downloads it in a local folder. The email_xkcd.py contains code to send the downloaded comic as an email attachment. But you don’t want to receive a duplicate comic if there is no new comic’s, right!? So, for this, I keep a record of the previous comic in a text file called comic_records.txt which I will read before sending out an email.

Cron Job

I followed Ole Michelsen’s article to create a Cron Job, which is straight forward in MacOS.

To run your python script every day of the week at 6 PM, you can do something like this:

  0 18 * * * cd /folder/where/your/script/resides/ && python 

Note: If you are using Gmail to send an email then you will need to allow less secure apps to access Gmail! The first time you try to access Gmail using Python, your access will not be granted and you will receive an email from Google saying, Review blocked sign-in attempt, click allowing access to less secure apps link and select Turn on and there you go, you can access your gmail using Python!

Youtube bot using Python!

Wouldn’t it be nice to get a video list along with the number of views and link to that video so that you need not visit each and every video of the conference you missed? Well, I have attempted to create such a script inspired by Miguel’s article.

I have used Python’s `requests`, `BeautifulSoup` and `multiprocessing` libraries to make this work.

The idea is simple, select a Python conference from `pyvideo.org` using `requests` module. Parse the request using `BeautifulSoup` and get all the video links of that conference. Visit each and every youtube link and collect stats like, ‘Title’, ‘URL’, and ‘Number of views’ and present it to the user.

The code can be found here. Hope you enjoy it!