0

我想知道在使用 AcademictwitterR 包时是否可以检索已在 Twitter 的推文中发布的图像的 media_url。我正在尝试遍历用户列表以获取他们的推文。我唯一缺少的是推文中的媒体网址,分别是我当前代码中的 .jpg。代码的其余部分对我来说非常好。我非常感谢任何建议/帮助。提前谢谢你们!

为了让您更好地了解我的问题,我使用以下代码:

require(academictwitteR)
library("writexl")
library(jsonlite)
library(data.table)

set_bearer()
get_bearer()
setwd("/Users/Kevin/example")
getwd()
handles <- read.csv("example.csv")
df <- data.frame(handles)
x <- c(t(df))

for (i in seq_along(x)) {
tweets <- get_all_tweets(
users = x[i],
start_tweets = "2020-05-26T00:00:00Z",
end_tweets = "2020-05-29T00:00:00Z",
is_retweet=FALSE,
is_reply=FALSE,
data_path = "data",
verbose = TRUE,
bind_tweets = FALSE,
export_query = TRUE,
n=Inf,
context_annotations=TRUE
)
}

data<-bind_tweets(data_path="data/",user = FALSE)
users<-bind_tweets(data_path="data/",user = TRUE)

data <- as.data.table(data)
users <- as.data.table(users)

names(users)[names(users)=="id"] <- "author_id"

data <- merge(data,users,by="author_id")

saveRDS(data,"Tweets.rds")

write.csv(data, file = "twitter_tweets.csv", row.names=FALSE)
4

0 回答 0