我正在探索使用 R
提取推文的不同方法我用过这个:
library("twitteR")
library("ROAuth")
download.file(url="http://curl.haxx.se/ca/cacert.pem",destfile="cacert.pem")
#create an object "cred" that will save the authenticated object that we can use for later sessions
cred <- OAuthFactory$new(consumerKey='XXXXXXXXXXXXXXXXXX',
consumerSecret='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
requestURL='https://api.twitter.com/oauth/request_token',
accessURL='https://api.twitter.com/oauth/access_token',
authURL='https://api.twitter.com/oauth/authorize')
# Executing the next step generates an output --> To enable the connection, please direct your web browser to: <hyperlink> . Note: You only need to do this part once
cred$handshake(cainfo="cacert.pem")
load("twitter authentication.Rdata")
registerTwitterOAuth(cred)
search.string <- "#GoT"
no.of.tweets <- 100
tweets <- searchTwitter(search.string, n=no.of.tweets, cainfo="cacert.pem",lang="en")
tweets
但我只能在一个月内检索tweets
所以我需要一种在代码之间添加timeline
的方法,以便我可以提取过去2-3
年的推文...
答案 0 :(得分:0)
答案 1 :(得分:0)
正如您所发现的,Twitter Search API仅提供对最近7天左右的推文的访问权限,并针对新近度进行了优化/可能不是完整的索引。
您有两种选择:
除此之外,您必须遵守公共API的限制和速率限制。