R: r tweets: Error: can only select one search type. Try type = 'recent'

R: r tweets: Error: can only select one search type. Try type = 'recent'

我正在使用 'rtweet' 包按位置收集推文。

  rt <- search_tweets(
      "lang:en",  lookup_coords("san francisco, CA", "country:US"), n = 10000

当我提到城市、州和国家/地区时出现以下错误。

Error: can only select one search type. Try type = 'recent'

rtweet::search_tweets 的文档告诉您需要指定要查找的推文类型。共有三个选项可供选择:"recent"、"popular"、"mixed"。您需要在通话中指定它们。

这里是一个不会报错的推文搜索调用(我指定的坐标是旧金山,我设置的半径是40公里,我也选了一个我确定会的词return 匹配)

first_batch <- rtweet::search_tweets(q= "Kanye",
                                     geocode = "37.773972,-122.431297,40km", n = 100, type = "recent",
                                     retryonratelimit = TRUE, parse = TRUE)

我稍微更改了你的调用,因此它不会引发错误,但搜索检索到 0 条推文(我想是因为 lookup_coords 是 returning 空的)

second_batch <- rtweet::search_tweets(q= "Kanye",
                             geocode = rtweet::lookup_coords("San Francisco, CA", "country:US"), n = 100, type = "recent",
                             retryonratelimit = TRUE, parse = TRUE)

我以前搜索过按位置搜索推文,建议你使用第一种方法。从Google抓取经纬度,设置半径。然后将它们传递给带有搜索词并指定类型参数的函数。