TwitterFingerprinting tool for Python (library)

Long ago, around 4 years ago already, I implemented a Twitter Fingerprinting tool in PHP that was available for everybody which unfortunately stopped working when the API changed. I was really excited because I could also help the Spanish police with another version of this online tool.

Recently, I decided to implement something similar in Python, but with a considerable difference: not using the Twitter API. There are many reasons:

  • Due to the own Twitter API limitation, you cannot use the application intensively. I do not know the limit nowadays, but long ago it was around 150 requests per hour and IP.
  • I do not usually like that the guys of Twitter know what I am doing with the API.
  • If you use the API, you have to make an account, and use certain credentials. Some people may not like this.
  • Less flexibility. With the API you only can do what you can only do. Obviously.

On the other hand, the basic disadvantage of not using the API and parsing code with regexps directly is that a small change in their website will make the code not work properly.

After saying this, here is the Github link of this small library where you can find more information.

An example of how to use it:

Get all the images uploaded from a specific user:

from TwitterFingerprint import TwitterFingerprint
tw = TwitterFingerprint("google")
tw.obtainLastTweets() # Get all tweets
tw.getPicturesLinks(savePath="images/",includeRTs=0)

Get the language, hashtags, and text (tweet) of the last 30 tweets:

from TwitterFingerprint import TwitterFingerprint
tw = TwitterFingerprint("google")
tw.obtainLastTweets(limit=30,verbose=False)
for tweet in tw.tweets:
	print(tweet["lang"],tweet["hashtags"],tweet["text"])

Get three histograms (months, weekdays, hours) of the last 500 tweets. Interesting when analyzing when someone is using Twitter.

from TwitterFingerprint import TwitterFingerprint
tw = TwitterFingerprint("google")
tw.obtainLastTweets(limit=500)
[histMonths,histWeekdays,histHours] = tw.getHistograms()

Leave a Reply

Your email address will not be published. Required fields are marked *