With the #Corona and #StayHome trending throughout the world, I got curious about what’s going on in people’s minds? How Moms are reacting with the school closed until the next session or how the high school kids are responding? Different people handling it in their own way in an attempt to stay safe. In this crisis period, Let’s find out what’s there on everyone’s mind!
1. Create Twitter Developer Account
We need to do the below steps:
- Set up a Twitter account if you do not have one already
- Using the Twitter account, we need to apply for a Developer Account first. The Link is here.
- Fill in some basic details like the reason to create a developer account or how you plan to use the Twitter API etc.
- After filling in the details, accept the Developer Agreement and verify the email address.
- Once all the details are filled in, a notification will pop up something like below:
Once your new Twitter Developer account application is reviewed by Twitter then they will send you an approval email.
2. Set up Twitter App
- Login to Twitter Developer Account
- Click on “Your name” on the right side top
- Then, click on “Apps”
- Next, click on “Create an App”
- Fill in App name and other details and click “Create“
- Once the APP is created the keys and he tokens o access Twitter will be generated
3. Install Libraries
Install the Tweepy and Twitter packages.
Now, we are ready to begin querying Twitter to see what we can learn from tweets! So, let’s be clear about what are we trying to do in this post. If we open Twitter and search for some topic, we see all the tweets below.
We want to achieve the same results by writing a few lines of python code. Then, in the next post, we can work on Sentiment Analysis and dig further.
I log in to Twitter and did an advanced search with words like “#corona” and language “English” and days from “01-Jan-2020”. in the search bar, it is searching for “#corona lang:en since:2020-01-01″
Let’s take a look at my first tweet result:
Let’s start coding and see if we can get the same result.
Yes, I got it! If I take a look at my output, the first tweet is from Scott Ford wishing “Happy Birthday”!
So, now we know how to search for tweets the way we do on Twitter. Let’s collect these tweets from Twitter and do some Text Analysis and then finally work on Sentiment Analysis.
For Reference:
My other posts on Twitter Streaming and Analysis are below:
- Text Analytics on #coronavirus trends in Twitter using Python
- Streaming Tweets from Twitter using Tweepy and Text Analytics
Thank You For Reading!