searchTwitter() 或 userTimeline() 中的有限结果
Limited results in searchTwitter() or userTimeline()
我正在尝试使用 searchTwitter()
and/or userTimeline()
获取推文
我想获取 twitterR API 允许获取的最大推文数量(我相信限制在 3000 左右。)
但结果我只收到很少的帖子(比如 83 或 146)。我确定有更多的帖子,当我检查该用户的时间轴(通过浏览器或应用程序)时,我看到有超过 3000 个帖子。
以下是我收到的消息。
r_stats <- searchTwitter("#ChangeToMeIs", n=2000)
Warning message:
In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, :
2000 tweets were requested but the API can only return 83
有什么我遗漏的吗?
PS:发帖前我已经检查了所有相关问题。在标记重复之前,请帮助我解决问题。
我从 git hub
安装 library twitteR
并且版本来自 git
而不是 CRAN
非常重要
比设置
setup_twitter_oauth("xxxxxxx", "xxxxx")
而且你可以像
一样使用表扬
从用户时间轴获取推文
ut <- userTimeline('xxxx', n=2000)
ut <- twListToDF(ut)
或搜索特定的 hastags
tweets<-twListToDF(searchTwitter("#f1", n=5000))
它非常适合我
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C LC_TIME=Swedish_Sweden.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] twitteR_1.1.9
loaded via a namespace (and not attached):
[1] bit_1.1-12 httr_1.1.0 rjson_0.2.15 plyr_1.8.3 R6_2.1.2 rsconnect_0.4.1.11 DBI_0.3.1 tools_3.2.2
[9] whisker_0.3-2 yaml_2.1.13 Rcpp_0.12.4 bit64_0.9-5 rCharts_0.4.5 RJSONIO_1.3-0 grid_3.2.2 lattice_0.20-33
实际上,您使用的是 Twitter Search API
,它只是 returns 个结果样本,而不是全面搜索。
你需要的是 Twitter Streaming API。
Please note that the Twitter search API does not return an exhaustive
list of tweets that match your search criteria, as Twitter only makes
available a sample of recent tweets. For a more comprehensive search,
you will need to use the Twitter streaming API, creating a database of
results and regularly updating them, or use an online service that can
do this for you.
来源:https://colinpriest.com/2015/07/04/tutorial-using-r-and-twitter-to-analyse-consumer-sentiment/
由于 twitteR
将被弃用,您需要做的是安装 rtweet
。
代码如下:
# Install and load the 'rtweet' package
install.packages("rtweet")
library(rtweet)
# whatever name you assigned to your created app
appname <- "tweet-search-app"
# api key (example below is not a real key)
key <- "9GmBeouvgfdljlBLryeIeqCHEt"
# api secret (example below is not a real key)
secret <- "ugdfdgdgrxOzjhlkhlxgdxllhoiofdtrrdytszghcv"
# create token named "twitter_token"
twitter_token <- create_token(
app = appname,
consumer_key = key,
consumer_secret = secret)
# Retrieve tweets for a particular hashtag
r_stats <- search_tweets("#ChangeToMeIs", n = 2000, token = twitter_token)
我正在尝试使用 searchTwitter()
and/or userTimeline()
获取推文
我想获取 twitterR API 允许获取的最大推文数量(我相信限制在 3000 左右。)
但结果我只收到很少的帖子(比如 83 或 146)。我确定有更多的帖子,当我检查该用户的时间轴(通过浏览器或应用程序)时,我看到有超过 3000 个帖子。
以下是我收到的消息。
r_stats <- searchTwitter("#ChangeToMeIs", n=2000)
Warning message:
In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, :
2000 tweets were requested but the API can only return 83
有什么我遗漏的吗?
PS:发帖前我已经检查了所有相关问题。在标记重复之前,请帮助我解决问题。
我从 git hub
安装 library twitteR
并且版本来自 git
而不是 CRAN
非常重要
比设置
setup_twitter_oauth("xxxxxxx", "xxxxx")
而且你可以像
一样使用表扬从用户时间轴获取推文
ut <- userTimeline('xxxx', n=2000)
ut <- twListToDF(ut)
或搜索特定的 hastags
tweets<-twListToDF(searchTwitter("#f1", n=5000))
它非常适合我
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C LC_TIME=Swedish_Sweden.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] twitteR_1.1.9
loaded via a namespace (and not attached):
[1] bit_1.1-12 httr_1.1.0 rjson_0.2.15 plyr_1.8.3 R6_2.1.2 rsconnect_0.4.1.11 DBI_0.3.1 tools_3.2.2
[9] whisker_0.3-2 yaml_2.1.13 Rcpp_0.12.4 bit64_0.9-5 rCharts_0.4.5 RJSONIO_1.3-0 grid_3.2.2 lattice_0.20-33
实际上,您使用的是 Twitter Search API
,它只是 returns 个结果样本,而不是全面搜索。
你需要的是 Twitter Streaming API。
Please note that the Twitter search API does not return an exhaustive list of tweets that match your search criteria, as Twitter only makes available a sample of recent tweets. For a more comprehensive search, you will need to use the Twitter streaming API, creating a database of results and regularly updating them, or use an online service that can do this for you.
来源:https://colinpriest.com/2015/07/04/tutorial-using-r-and-twitter-to-analyse-consumer-sentiment/
由于 twitteR
将被弃用,您需要做的是安装 rtweet
。
代码如下:
# Install and load the 'rtweet' package
install.packages("rtweet")
library(rtweet)
# whatever name you assigned to your created app
appname <- "tweet-search-app"
# api key (example below is not a real key)
key <- "9GmBeouvgfdljlBLryeIeqCHEt"
# api secret (example below is not a real key)
secret <- "ugdfdgdgrxOzjhlkhlxgdxllhoiofdtrrdytszghcv"
# create token named "twitter_token"
twitter_token <- create_token(
app = appname,
consumer_key = key,
consumer_secret = secret)
# Retrieve tweets for a particular hashtag
r_stats <- search_tweets("#ChangeToMeIs", n = 2000, token = twitter_token)