-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathData Extraction
More file actions
69 lines (43 loc) · 1.6 KB
/
Data Extraction
File metadata and controls
69 lines (43 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Step 1: Setting Up Twitter Application
Go to https://apps.twitter.com/app/new
Create a new application. Provide all the necessary details.
Generate Token Key.
Please note the Consumer key, Consumer Secret, Access Token, and Access Token Secret numbers as they will be used in R later
Step 2: Setting Up Twitter Application
#Clear R Environment
rm(list=ls())
# Load the required R libraries
install.packages("RColorBrewer")
install.packages("tm")
install.packages("wordcloud")
install.packages('base64enc')
install.packages('ROAuth')
install.packages('plyr')
install.packages('stringr')
install.packages('twitteR')
library(RColorBrewer)
library(wordcloud)
library(tm)
library(twitteR)
library(ROAuth)
library(plyr)
library(stringr)
library(base64enc)
download.file(url="http://curl.haxx.se/ca/cacert.pem",destfile="cacert.pem")
#Enter the values that we have found in the previous step
consumerKey <- "xxx"
consumerSecret <- "xxx"
accessToken <- "xxx"
accessTokenSecret <- "xxx"
# Set constant requestURL
requestURL <- "https://api.twitter.com/oauth/request_token"
# Set constant accessURL
accessURL <- "https://api.twitter.com/oauth/access_token"
# Set constant authURL
authURL <- "https://api.twitter.com/oauth/authorize"
setup_twitter_oauth(consumerKey, consumerSecret, accessToken, accessTokenSecret)
#Objectname <- searchTwitter(searchString, n=no.of tweets, lang=NULL)
namo <- searchTwitter('narendra modi', n=3000, lang=NULL)
tweet <- userTimeline('@elonmusk',n=100) #to find the tweets of any specific user
homeTimeline (n=15) #tweets from own timeline
mentions (n=15) #tweets where you have been tagged