问题描述
限时送ChatGPT账号..我正在尝试使用 twitteR 包提取推文,但是当我按照他们在文档中的方式指定地理编码时,我在通过 searchTwitter 功能获取它们时遇到了问题.请看下面的代码:
I'm trying to pull tweets using the twitteR package, but I'm having an issue getting them through the searchTwitter function when I specify a geocode the way they have it in their docs. Please see code below:
#Oauth code (successful authentication)
keyword = "the"
statuses = searchTwitter(keyword, n=100, lang="en",sinceID = NULL, geocode="39.312957, -76.618119, 10km",retryOnRateLimit=10)
当我省略 geocode="39.312957, -76.618119, 10km",
时,代码可以完美运行,但是当我包含它时,我得到以下内容:
Code works perfectly when I leave out geocode="39.312957, -76.618119, 10km",
, but when I include it, I get the following:
Warning message:
In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, :
100 tweets were requested but the API can only return 0
我以为我的格式可能有误,但根据 twitteR CRAN 页面,该字符串的格式正确(我也尝试在 km 和 mi 之间切换).
I thought maybe my formatting was wrong but based on the twitteR CRAN page the string is in the right format (I also tried switching between km and mi).
有没有其他人经历过这种情况或知道搜索特定地理编码的更好方法?他们会否弃用地理编码功能?
Has anyone else experienced this or know a better way to search for a specific geocode? Would they have deprecated the geocode functionality?
我正在寻找来自巴尔的摩的推文,所以如果有更好的方法,我会全力以赴.(顺便说一句,我想避免尝试拉取所有推文然后过滤自己,因为我认为我会很快达到数据限制并错过我正在寻找的内容)
I'm looking for tweets from Baltimore so if there is a better way to do so, I'm all ears. (By the way, I want to avoid trying to pull all tweets and then filter myself because I think I will hit the data limit fairly quickly and miss out on what I'm looking for)
谢谢!
推荐答案
我认为您需要删除 geocode
参数中的空格:
I believe you need to remove the spaces in the geocode
parameter:
statuses = searchTwitter(keyword, n=100, lang="en",sinceID = NULL, geocode="39.312957,-76.618119,10km",retryOnRateLimit=10)
FWIW 在将 URL 提交到脚本之前,您可以使用 Twitter 桌面客户端开发"控制台来测试 URL.
FWIW You can use the Twitter desktop client "Develop" console to test out URLs before committing them into scripts.
这篇关于R twitteR searchTwitter 地理编码警告/错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论