【发布时间】:2018-04-17 22:07:52
【问题描述】:
我正在使用R 的twitteR 包来收集一些推文。但是,我注意到searchTwitter 函数返回的推文文本不是完整的推文文本,而是被删减到正好等于 140 个字符,其余文本被网络上推文的链接替换。
以我找到的一条推文为例:
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"
如果我go to this tweet via my web browser,很明显twitteR 将文本缩短为 140 个字符,并包含指向包含整个文本的推文的链接。
我在twitteR 文档中没有看到任何提及。有没有办法在搜索过程中保留整个推文文本?
我的假设是这与此处引用的 Twitter 字符长度的变化有关:https://developer.twitter.com/en/docs/tweets/tweet-updates(在“兼容模式 JSON 渲染”中)。这意味着我需要检索 full_text 字段,而不是 text 字段。但是,这似乎不是由twitteR 提供的。
【问题讨论】:
-
当你点击 SHORTEDURL 时,它会重定向到推文吗?
-
@HenryNavarro 你是对的,确实如此
标签: r string twitter url-shortener twitter-r