r-使用rtweet软件包实时记录结果



我正在使用R包rtweet来流式传输实时推文。

一切都还可以,但我想要的是自动将信息存储在Google Big Query中,并将其显示在Data Studio上,并且该信息应该每X次更新一次(例如,5分钟(。

我该怎么做?问题是,在重新命名时,R会话很忙,所以我不能做任何其他事情。

我也会考虑停止流媒体一秒钟来存储信息,并在。。。

这是我的代码:

library(rtweet)
library(bigrquery)
token <- create_token(
app = "app name",
consumer_key = "consumer_key ",
consumer_secret = "consumer_secret ",
acess_token = "acess_token",
access_secret = "access_secret")
palabras <- ""
streamtime <- 2 * 60
rt <- stream_tweets(q = palabras, timeout = streamtime)
#This is what I want to do each X time to store the information in Big Query:
insert_upload_job("project id", "dataset name", "table name", df, write_disposition = "WRITE_APPEND")

感谢大家,

我对R不太了解,但我遇到了类似的情况,在stream_tweets()运行期间没有什么可做的,只能等待超时。

我不确定这是否可能,但是stream_tweets()创建了一个JSON对象,该对象在函数运行的同时被填充。不可能运行其他R脚本,当新项目添加到JSON时,将其存储到Big Query?比如,把你的代码一分为二,然后并行运行?

希望我的回答能给你一些想法。

最新更新