What did I do this Summer – Part 2(Summer-Internship)

Its been about a month since I finished my summer-internship, glad am finally blogging it ๐Ÿ™‚

Hey there ! This blog post is the second blog post on my summer ! After FUDCon, I left for Bangalore where I interned in a startup- Eventifier which was recently acquired by BookMyShow. I was excited to work with awesome people and wanted to get the best out of it.

I was not really very sure of things when I reached ! But then… ๐Ÿ˜› Someone said “Things will always move on !” -@harisibrahimkv

So, I met Haris, Praseetha, Sharat, Unni, Saud, Nazim, Nawaz, and Jazeel in the order as listed. ๐Ÿ˜› They are really a fun bunch of people to hang out with, who do skateboarding (oh yes, they do :P) ย and discuss on topics, debate and laugh over the same ๐Ÿ™‚

Ah! they are cool coders too ! On my first day, Saud who is the co-founder told me that I will be working on the Analytics of the product, and would hack on the Backend part that used Django. I went through the code-base which was clean, and beautifully written. Sharat helped me get it all set on my system, and I was good to go ! ๐Ÿ™‚

So, what did I work on ??

Task 1: I worked on getting Social-Insights of a brand/company based on their respective twitter info.

upload

I used Python-Requests to extract info with the Twitter API, and the Twitter-Counter API. Thanks to my mentor @harisibrahimkv who has helped me throughout to explain stuff with patience.(He would be like, “You really can’t see the bug !” and then he goes ahead and explains). It used to be really fun coding with him, haven’t seen someone as humble as him. Later, I also got to work on another task under the mentorship of Nazim, CTO of Eventifier.

So reader, hi again ! Try and imagine a situation, where you host a site and a celebrity or well known personality tweets about the same. Wouldn’t you want to showcase it? Wouldn’t you want to extract more info of that interested customer who also happens to be a celeb ? Now imagine how many followers would also be interested in the product !! And why wouldn’t they! ๐Ÿ˜‰ Now these are just a few features that team Eventifier hacks on. This was my first task to get the tweets of the celebrities who tweet about certain products.

So, here I am, ย writing this blog to explain how Python-Requests made life easier for me.

Requests is an Apache2 Licensed HTTP library, written in Python. Pythonโ€™s standard urllib2 module provides most of the HTTP capabilities one needs, but the API is thoroughly broken. Previously, one would, put off doing HTTP requests in Python because the API was such a pain. One would end up running wget at the command line and copy paste html into files and load the files in python because open() was an easier API. But, then !! ๐Ÿ™‚

Requests to the rescue !!

  • Requests have a way better API design.
  • To get information all one needs to do is use .get() as a method.
  • Auth is an optional parameter in Requests, and
  • status is a field not a method.

It is written to make HTTP requests way easier. Such an improvement ! ๐Ÿ™‚

Screenshot from 2015-10-09 02:51:12
urllib.py
Screenshot from 2015-10-09 02:51:54
urllib.py

Fig : This is sad and shouldn’t be this way !

Requests is the perfect example how beautiful an API can be with the right level of abstraction.

Python HTTP: When in doubt, or when not in doubt, use Requests. Beautiful, simple, Pythonic.

For example, to get a webpage :

>>> r = requests.get('http://www.python-requests.org/en/latest/')

This is how one can simply make a get request; then again what about other HTTP request types: PUT, DELETE. Well, they are all just similar.
>>> r = requests.put("http://httpbin.org/put")
>>> r = requests.delete("http://httpbin.org/delete")

Now, how did requests be my saviour !? Like I mentioned previously, for my task I would have to hit the Twitter-Counter API at regular intervals to extract twitter info of the customers, thus all I had to do was to ask the requests API to hit the tweet-url and extract the required information of the user, and showcase it for the product.

During this, I learned to use tools like tmux, and other python hacks that helped me get only the required data within a tolerable time limit.

2nd task : In my next task, I got to work with Nazim who wanted me to get the twitter-followers information of a user and display it in the form of graphs with respect to time. Here again, I had to use the requests API to hit the tweet-url using the Twitter-Counter API to extract the followers info.

From the graph, one can conclude the growth in the followers count, information of the followers, their interests and more.

During this, I learned about the importance of a cache DB for a Django product, for immediate retrieval of data to display.

Before my internship got over I also hacked on a Django app for the Djangothon that was conducted by Hackerearth, where I participated with Praseetha and Sharat. That will be in my next post, so stay tuned !! ๐Ÿ™‚ Goodbye reader !

For detailed info on Python-Requests, one can refer the documentation :

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s