Fetching name of Twitter users using Python.

Python is awesome, not because everyone is saying it. It’s awesome because python allows you to do almost everything you want.
Just few days back I was trying to search user name of those, whose twitter handle starts from @1 to @100. So, I just wrote a quick python script that performs the same task and shows you all the user name in your terminal.
Here is the code :


import urllib2

from BeautifulSoup import BeautifulSoup

for x in xrange(1,100):

    print BeautifulSoup(urllib2.urlopen("https://www.twitter.com/"+str(x))).title.string

    x += 1

Now, save this code as twitter.py and run it via terminal.

Note :

If you get any error regarding modules then try :

  • sudo pip install urllib2
  • sudo pip install BeautifulSoup
Advertisements

One thought on “Fetching name of Twitter users using Python.

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