Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 推特返回的推特被缩短_R_String_Twitter_Url Shortener_Twitter R - Fatal编程技术网

R 推特返回的推特被缩短

R 推特返回的推特被缩短,r,string,twitter,url-shortener,twitter-r,R,String,Twitter,Url Shortener,Twitter R,我正在使用twitteR软件包R收集一些tweet。但是,我注意到,searchTwitter函数返回的Tweet文本并不是完整的Tweet文本,而是经过删节,精确地等于140个字符,其余文本被web上的Tweet链接替换 以我找到的tweet为例: require(twitteR) require(ROAuth) # authorize twitter with consmuer and access key/secret setup_twitter_oauth(AAA, BBB, CCC,

我正在使用
twitteR
软件包
R
收集一些tweet。但是,我注意到,
searchTwitter
函数返回的Tweet文本并不是完整的Tweet文本,而是经过删节,精确地等于140个字符,其余文本被web上的Tweet链接替换

以我找到的tweet为例:

require(twitteR)
require(ROAuth)

# authorize twitter with consmuer and access key/secret
setup_twitter_oauth(AAA, BBB, CCC, DDD)   # actual secret codes go here...

# get sample tweet
tweet <- searchTwitter("When I was driving around earlier this afternoon I only saw two Hunters",
                       n=500,
                       since = "2017-11-04",
                       until = "2017-11-05",
                       retryOnRateLimit=5000)

# print tweet
tweet[[1]]
[1] "_TooCrazyFox_: When I was driving around earlier this afternoon I only saw two Hunters but it was during the midday break. I didn'… *SHORTENEDURL*"
# the *SHORTENEDURL* is actually a link that brings you to the tweet; stackoverflow didn't want me to a put shortened urls in here

# convert to data frame
df <- twListToDF(tweet)

# output text and ID
df$text
[1] "When I was driving around earlier this afternoon I only saw two Hunters but it was during the midday break. I didn'… *SHORTENEDURL*"

df$id
[1] "926943636641763328"
require(推特)
要求(ROAuth)
#使用consmuer和访问密钥/密码授权twitter
设置_twitter_oauth(AAA、BBB、CCC、DDD)#实际密码在这里。。。
#获取示例推文
tweet。你应该改用

您可以下载,但目前我建议从Github下载开发版本。默认情况下,dev版本将返回tweets的全文。它还将返回全文、转发或引用状态的原始文本

要从Github安装最新版本的rtweet,请使用该软件包

安装后,加载rtweet包

## load rtweet
library(rtweet)
rtweet有一个专门的。它包括一个小插曲。如果您遵循vignette中的步骤,您只需[每台机器]执行一次授权过程

要搜索tweets,请使用
搜索tweets()
功能

# get sample tweet
rt <- search_tweets(
  "When I was driving around earlier this afternoon I only saw two Hunters",
  n = 500
)
## lookup tweet
tweet <- lookup_statuses("926943636641763328")
要按ID查找Twitter状态,请使用
lookup\u statuses()
函数

# get sample tweet
rt <- search_tweets(
  "When I was driving around earlier this afternoon I only saw two Hunters",
  n = 500
)
## lookup tweet
tweet <- lookup_statuses("926943636641763328")

当你点击SHORTEDURL时,它会重定向到tweet吗?@HenryNavarro你是对的,它会感谢新的改进包!我一直在测试它,将现有代码转换为
rtweets
似乎非常简单。只是确认一下,没有等效于
的,因为
直到
允许搜索特定的日期范围?在文档/渐晕图中没有看到任何内容,但我想我应该仔细检查一下。您可以在实际查询中包含这些参数。例如,
sarch_tweet(“从2017-11-01到2017-11-06的早期驾驶”,n=100)
。我最近更新了很多文档。我可能应该举一些这样的例子:)。
## lookup tweet
tweet <- lookup_statuses("926943636641763328")
> tweet$text
[1] "When I was driving around earlier this afternoon I only saw two Hunters but it was during the midday break. I didn't have my camera otherwise I would have taken some photos of the standing corn fields in the snow. I'll do it later., maybe tomorrow.\n#harvest17"