The following 10 tasks will make you realise the power python provides and how it acts as a bridge to endless possibilties.
Task 1 :
Browse the website
https://whatthecommit.com . Refresh it several times, notice how it changes the message.
view-source:https://whatthecommit.com/ in Google Chrome and repeat the same. Notice which part of the HTML code of the webpage changes
Write a code in python to open the webpage and extract just the message. Make it run in a loop 50 times and extract 50 messages.
You might need these keywords to start searching. Google is your friend.
Loops in python python requests make http requests in python using requests make GET request in python using requests Beautiful Soup Extract a tag data from html using beautiful soup
Updating social media is something everyone is addicted to. However there exists a way where your code can update your social media for you. In this exercise you will learn how python can be used to tweet on your behalf.
Twitter ( and almost all major web based products) offer something called an API ( or Application Programming Interface) which enables code to interact with their service.
In this exercise you need to write a peice of code which will take an input from you and tweet it on your behalf. ( You can obviously then place the line which is actually responsible for tweet in a loop or take the tweet text from any dynamic variable, the possibilities are endless. Somebody wrote a twitter bot which takes the locations from tweets targeted to it and replies with the uber fare between the distance. :P )
You might need these keywords to get started
python twitter api how to generate twiter api keys install twitter python
Extra: There is something called the
streaming API which gives you a pipe to all the tweets happening around the world in real time.
You can use this data to compare the tweets for any two keywords or pass this data to any Sentiment analysis API for fun.
We are used to getting notifications for every event. SMS is still one of the most common methods if not the most common (push notifications).
We have already learnt about web APIs. In this task we will learn about a web service which enables us to send SMS, Make calls with text to speech and even IVR services.
The name of one such service is
For this task write code which will send a sms with text of you choice.
For this task you will need to signup on twilio and add your number as verified number and then grab the API keys.
twilio api twilio python package twilio api keys
We are used to getting captchas on actions like login/signup. There are several types (Text/Audio/Google Recaptcha) and are meant to prevent automated requests.
This task deals with trying to solve the image captcha using OCR (Optical character recognition). There are libraries already available for OCR, however in a captcha, sometimes the characters are not clean and the image might need some enhancements for the OCR to give accurate results.
At this point we already have the knowledge to open a webpage, navigate to the image tag for an image captcha, make another request to download the image and feed it to the OCR to see the results.
One good OCR library is Tesseract, which has a python module available
You just need to search for how to pass on the image to the OCR and get the output.
You can also use this output and make the
HTTP POST request with the
form data using
pytesseract making HTTP POST form request using python cleaning image before passing on to OCR
HINT: I had written a code using most of the concepts mentioed above 2 Years back, which is available here for reference.
Subscribe to Iniquitous Psyche
Get the latest posts delivered right to your inbox