【发布时间】:2019-01-12 19:43:53
【问题描述】:
所以我想向一个 API 发出多个请求以加快结果速度,因为串行速度太慢了。因此,我尝试使用 GetURI,但是,API 不返回任何值,而 GET 请求则返回!
所以我尝试了各种解决方案,例如 GETURI、GETURL 和 getURIAsynchronous,但是,它们都没有返回值。我想这是因为 API 需要很长时间来处理查询。我将包含我的测试密钥,但是假设这不会被滥用
links<- c("zalando.nl", "bol.com")
key <- "SILB-DBCA-4523"
APIcall <- paste0("http://www.siteprice.org/WorthApi.aspx?type=1&key=", key, "&url=", links)
#With GET, so serial
res <-GET(APIcall[1])
res1 <- rawToChar(res$content)
as.integer(unlist(xmlToList(xmlParse(res1)))[2])
#With GetURI
res <- getURIAsynchronous(APIcall)
res1 <- rawToChar(res$content)
as.integer(unlist(xmlToList(xmlParse(res1)))
getURIAsynchronous 应该返回 GET 请求的值,但它没有
【问题讨论】: