Trends Extraction

Create a twitter account. Sign up and sign in. Click on to the manage apps. Create a new application with name and description. Create the access token and note the Consumer token and Consumer Secret. 

Refer the following link to create a Twitter API to extract tweets. with pictorial explanation.

The package to be used to extract the current Twitter trends using R tool is,
twitteR - it provides interface to the Twitter API.
library(twitteR)

As the next step, we have to set the WOEID (Where On Earth IDentifier). For India, the WOEID is 23424848
woeid <- 23424848

The next step is to set up the Twitter Authentication. For this, we need, API Key, API Secret, Consumer Key and Consumer Secret.
api_key <- "xxxxxxx"
api_secret <- "xxxxxxx"
consumer_key <- "xxxxxxx"
consumer_secret <- "xxxxxxx"

Set up the direct authentication using the method setup_twitter_auth() 
setup_twitter_auth(api_key, api_secret, consumer_key, consumer_secret)

When the twitter allows direct authentication, we can use the function getTrends() with the attribute WOEID.
current_trends <- getTrends(woeid)

Then set the Trend Date in the current_trends to the System Date.
current_trends ["trend_date"] <- Sys.Date()

Write the trends extracted into a CSV file using the command,
write.csv(current_trends, file = "trends.csv", row.names = FALSE)

current_trends

                                                                                                                                           name
1                                                                                                                                        #DDvMI
2                                                                                                                              #KarnatakaLesson
3                                                                                                                                      #Gorilla
4                                                                                                                                  #BeLikeGroot
5                                                                                                                                    #InPatiala
6                                                                                                                               Miss India 2018
7                                                                                                                                        WICKET
8                                                                                                             North East Democratic Alliance
9                                                                                                                                A. Siddaramiah
10                                                                                                                              National Anthem
11                                                                                                                             Rajasthan Royals
12                                                                                                                                       FA Cup
13                                                                                                                                      Chelsea
14                                                                                                                                Zojila Tunnel
15                                                                                                                              #GreenGoodDeeds
16                                                                                                                                    #FrenchGP
17                                                                                                                                       #Saaho
18                                                                                                                                #Chhattisgarh
19                                                                                                                                    #CSKvKXIP
20                                                                                                                               #RenukaShahane
21                                                                                                                                #SundayFunday
22                                                                                                                                   #MasalaDay
23                                                                                                                                 #SEMAIn5Days
24                                                                                                                                  #Nadodigal2
25                                                                                                                                #RoyalWedding
26                                                                                                                                     #SRHvKKR
27                                                                                                                            #HappyBirthdayNTR
28                                                                                                                          #CongressDefeatsBJP
29                                                                                                                                      #RRvRCB
30                                                                                                                                  #FACupFinal
31                                                                                                                    #WhyEvidencesNeglected
32                                                                                                                     #हल्ला_बोल_दरवाजा_खोल
33                                                                                                           #FukreyReturnsOnANDPictures
34                                                                                                                                   #Deadpool2
35                                                                                                                       #RajiniMakkalMandram
36                                                                                                                              #IndiaTVSamvaad
37                                                                                                                           #MailMantraKolkata


The current trends on 20th May 2018 at 18.45 IST has been extracted.
India is currently on IPL Fever and that too yesterday and today, very interesting rivals for the teams to enter into the playoffs.
Now, the Do or Die match for MI is going on and that's trending first with the hashtag #DDvsMI followed by Infinity Wars character.
The next IPL Match between the CSK and KXIP is trending at 20th place.
Then the other movie details and politics details are as above.

The below frame shows the CSV file of the extracted current Twitter Trends.

Comments

  1. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.data science course in indore

    ReplyDelete

Post a Comment