[r]通过POST请求从互联网获取数据的问题

时间:2018-12-17 12:31:37

标签: r post httr

我正在尝试从带有R的网站获取数据。XHR中的请求标头是这样的:

Request URL: https://bi.cbi.ir/api/chartdata/getdata
Request Method: POST
Status Code: 200 OK
Remote Address: 217.218.78.58:443
Referrer Policy: no-referrer-when-downgrade

Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: 326
Content-Type: application/json
Cookie: __RequestVerificationToken=iovG1l3F2bEukN-w7nW9rNQgFpLycTL97dHE1g9_1TOcBimWnEINskcLJb3x7o2hEW0lAIvCoNUxN_Cni5yXM0y6rcHodI-5F5D_VdASLK41; TS01b59e8b_26=015d206c4e850b3e83509f364e3b142c2ff9966cc6a8f8d7696b945890cc80ccfa34119c8c8124c953ff000e440573581fe35b5fb21d2dcfeffda6a9691776067e01988db7; sadaf-dashboard=3BFBE624C8FA3240F4A5B285900BAD2A6415AA3663538BA71F20BD3B1481314E1684873DB0714A4D88BDAA1FAD10066A1D48D7F11D2F8DCCD53D87DC7A4121480F82E24548D3299B9363B6E69BD139464A2AB7A31F83EB2EEA2E0132AF056EC57DB5C877718A8349C6D244E5C8E920129FBF6CEC7D46451C683F5CF4FFFB87C6933DA3DB46814D365B6A6D3A7CAF4BC155612257A09A2E7A44995D0C79CF036207B2D18553B6F6A6AB2787D52741CFBB3825EED250C882CCD405AFE58158586301A061F30F7C64AB79DC0549ECBD5984E2FF51BE3CF1A891097E50E5070E33DEF416FD2F0681B3E5A19D16A8DE82AAEADBEEC75F9868314B6B8F33894197F7A25092E1CA559D92F2B265C44303273A8A1843D44E58DA7887FEE9D9FE4E6ACE10D6D376CC3D2AB8313CCA244F0190D8BC; TS01b59e8b=01bbddaca76a050c42989f8ce88d78ff5ba36d939a1a9ddf718ac942b376602b646c92cae599f170b289e745e04b27b051bb8aa9904ca0ded7d2316d875316050458b8ff1aed95d0f42929204904a42c2fed1c954c
Host: bi.cbi.ir
Origin: https://bi.cbi.ir
Referer: https://bi.cbi.ir/sadaf/dashboard/YKDhOQJC5nS3
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
X-Requested-With: XMLHttpRequest

我使用以下代码获取数据(带有httr包):

p=POST("https://bi.cbi.ir/api/chartdata/getdata" , encode = c("multipart", "form", "json", "raw"))

但似乎出了点问题。首先:

   p$status_code
500

但是我想应该是200(关于标头请求中的信息)。 第二:

content(p, 'parse')

没有显示数据。

我猜问题出在编码部分。站点的Accept-Encoding是(gzip,deflate,br),但是R中的POST命令具有以下编码选项: (“ multipart”,“ form”,“ json”,“ raw”)

出什么问题了?我做错了什么?

非常感谢您。

0 个答案:

没有答案