【发布时间】:2018-04-03 22:15:05
【问题描述】:
我的目标是从 Shopify 导入客户的订单历史记录。 Shopify 只允许我每个请求导入 250 个订单,但我的客户有数千个。
这是(基本上)我当前使用 httr 的工作解决方案,非常慢
fetchedList <- list()
# Loop through pages of orders and collect them
for(pg in 1:10){
requestURL <- paste0("https://abc-store.myshopify.com/admin/orders.json?page=", p)
fetched <- httr::GET(
url = requestURL,
httr::add_headers(Accept = "application/json"),
httr::authenticate(user = "foo", password = "bar")
)
# Append the fetched response to fetchedList
fetchedList <- c(fetchedList, list(fetched))
}
# Process the results...
我想通过发出多个并发请求来加快速度。我怎样才能做到这一点? curl 和 RCurl 似乎都支持这个,但我对 HTTP 还很陌生,无法让任何一个解决方案都能正常工作。
【问题讨论】: