我想用 R STudio 从 Guardian api 获取所有关于基因组编辑的文章。我尝试了一些代码并得到了几个错误。
data <- fromJSON("https://content.guardianapis.com/search?q=genome%20editing&show-
blocks=body&&api-key=myapikey&page-size=200")
number_calls <- data$response$pages
api_calls <- paste("https://content.guardianapis.com/search?q=genome%20editing&show-
blocks=body&api-key=myapikey&page-
size=200page=", as.character(c(1:number_calls)), sep = "")
DatafromCall <- function(x) {
data <- fromJSON(x)
body <- data$response$results$blocks$body
textContent <- vector()
for (i in seq_along(body)) {
textContent[i] <- ifelse(is.null(body[[i]]$bodyTextSummary), NA,
body[[i]]$bodyTextSummary)
}
}
for (i in 1:number_calls) {
all.data <- rbind(DataframeFromCall(api_calls[i]))
}
我在 open.connection(con, "rb") 中遇到错误:HTTP 错误 400
library(guardianapi)
Genomeediting <- gu_content(query= "genome%20editing")
我在 open.connection(con, "rb") 中遇到错误:HTTP 错误 403
有什么建议么?