Member-only story

Python — How to Extract Tweets from Twitter

Ryan Arjun
6 min readAug 26, 2020

--

If you are working as Python developer and you have to extract tweets from Twitter for any specific hashtag then there are a lot of libraries which help us to accomplish this task.

Step 1 — How do we get a Twitter Consumer Key and Consumer Secret key?

First of all, we have to create a Twitter account and get the necessary credentials on the Twitter developer platform to access the Twitter API by following these steps:

  1. Go to https://dev.twitter.com/apps/new and log in, if necessary
  2. Supply the necessary required fields, accept the Terms Of Service, and solve the CAPTCHA.
  3. Submit the form
  4. Go to the API Keys tab, there we will find our Consumer key and Consumer secret keys.
Twitter Consumer Key and Consumer Secret key
Now, we can set the permission on the Twitter developer platform as given above

Step 2 — How do we connect to the Twitter API

Now that we are ready with the Twitter credentials required, let’s move on to the next stage, which is data extraction. We are using tweepy library to extract the tweets. If you don’t have this library then you can install it by using pip

--

--

Ryan Arjun
Ryan Arjun

Written by Ryan Arjun

BI Specialist || Azure || AWS || GCP — SQL|Python|PySpark — Talend, Alteryx, SSIS — PowerBI, Tableau, SSRS

No responses yet