Skip to content

Yukti-09/Extracting-Data-From-Twitter

Repository files navigation

Extracting-Data-From-Twitter

Application and Authorization

  1. Apply for a Twitter Developer Account.
  2. Upon verification create an application.
  3. Install tweepy.
  4. Authorize via running the following code (using your own consumer key, consumer secret, access token and access secret) [AUTHORIZATION CODE]

Generate your own twitter handle

The following code enables us to randomly generate a username. If the username already exists, the ID of the user is printed and if it does not exist, it is indicated that the username is free for usage. [RANDOMLY GENERATE USERNAME]

Your own Timeline

In order to pull ten most recent tweets from your Twitter feed the following code can be followed. [OWN TIMELINE CODE]

Get Data from Twitter Handle

In order to pull data from a twitter handle the following code can be followed. [GET DATA FROM HANDLE]
Here, 150 of the most recent tweets of the CEO of Twitter (Twitter Handle Name: jack) have been extracted. Date and time, tweet id and tweet have been printed.

Get Data from Twitter Phrases

In order to pull data from a twitter handle the following code can be followed. [GET DATA FROM PHRASES]
Here, 150 of the most recent tweets of the phrase '2020 US Election' have been extracted. Date and time, tweet id and tweet have been printed.