我偶然发现了一个错误:
> getBDLsearch("czas")
Error in file(con, "r") : cannot open the connection
...所以我开始拆解以找到问题所在的功能。这很简单,所以我只是粘贴它:
require(htmltools)
getBDLsearch <- function(query = "", debug = 0, raw = FALSE) {
url <- paste0('https://api.mojepanstwo.pl/bdl/search?q=', htmlEscape(query))
if (raw) {
document <- jsonlite::fromJSON(txt = url,simplifyVector=FALSE)
return(document)
}
else {
document <- jsonlite::fromJSON(txt = url,simplifyDataFrame=TRUE)
return(document)
}
}
(https://github.com/pbiecek/SmarterPoland)
当我手动运行后续行时,它就像一个魅力和变量&#34; document&#34;很好地填补了。我好奇,为什么会这样?