尝试使用curl包在r中编写curl命令让我迷路了。
我的curl命令是
curl -H "Accept: application/json+v3" -H "x-api-key: XXXXX" \https://beta.check-mot.service.gov.uk/trade/vehicles/mot-tests\?page=[0-58002]
我尝试了以下
library(curl)
h <- new_handle()
handle_setopt(h);
handle_setheaders(h,
'page'='[0-58002]',
'Accept' = 'application/json',
'x-api-key' = 'XXXXX'
)
tmp <- tempfile()
curl_download("https://beta.check-mot.service.gov.uk/trade/vehicles/mot-tests", destfile = tmp, handle = h)
但这似乎不起作用。我究竟做错了什么?我知道最初的curl命令有效,但不适用于r版本。
答案 0 :(得分:0)
我想你想要
library(curl)
h <- new_handle()
handle_setopt(h, verbose = TRUE)
handle_setheaders(h, .list = list(
'Accept' = 'application/json',
'x-api-key' = 'XXXXX')
)
tmp <- tempfile()
curl_download("https://beta.check-mot.service.gov.uk/trade/vehicles/mot-tests?page=[0-58002]", destfile = tmp, handle = h)
handle_setopt(h, verbose = TRUE)
获取详细的curl输出,将帮助您调试任何问题。查询参数放在网址中,而不是标题中