从R中的POST请求捕获json响应

时间:2018-08-01 06:52:58

标签: r httr

网站:wwww.draftfantasyfootball.co.uk /

使用Firefox上的inspect元素中的network标签,我可以找到以下内容:

enter image description here

enter image description here

使用R,如果可能的话,我希望能够生成相同的JSON响应供使用。

我尝试过:

`library(httr)

JSON<- POST(url = "https://draftfantasyfootball.co.uk/draft   /HPKjiKr4QdfFiJ6qZ",
 encode = "form",
 body = list(`Host`= "draftfantasyfootball.co.uk",
             `User-Agent`= "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0",
             `Accept`= "*/*",
               `Accept-Language`= "en-GB,en;q=0.5",
             `Accept-Encoding`= "gzip, deflate, br",
             `Referer`= "https://draftfantasyfootball.co.uk/draft/HPKjiKr4QdfFiJ6qZ",
             `content-type`= "application/json",
             `meteor-login-token`= "VlUSpVcIfN0Y2NotwNh7AnrXR1DTdbJrRcXMTgj2wM5",
             `origin`= "https://draftfantasyfootball.co.uk",
             `Content-Length`= "2043",
             `Cookie`= "ajs_user_id=%22Tx7TjaEsoxzPQJZ8q%22; ajs_group_id=null; _ga=GA1.3.722232030.1455049950; ajs_anonymous_id=%22bcfc2f78-7226-4d9b-b6c4-e2fa4f876595%22; amplitude_iddraftfantasyfootball.co.uk=eyJkZXZpY2VJZCI6IjA0NjFjM2JmLTk2NDctNGNjYS1iYmM0LTE3NTQxM2UyMmU5MSIsInVzZXJJZCI6IlR4N1RqYUVzb3h6UFFKWjhxIiwiZ2xvYmFsVXNlclByb3BlcnRpZXMiOnsiZW1haWwiOiJhbGV4ZGVudmlyQGdtYWlsLmNvbSIsIkV4cGVyaW1lbnQ6IHNob3cgbW9kYWxzIGFmdGVyIGpvaW5pbmcgbGVhZ3VlIjpmYWxzZSwiaWQiOiJUeDdUamFFc294elBRSlo4cSJ9LCJvcHRPdXQiOmZhbHNlfQ==; mp_ea7eecba53313f21feb8e49b94f188b5_mixpanel=%7B%22distinct_id%22%3A%20%22Tx7TjaEsoxzPQJZ8q%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%2C%22mp_name_tag%22%3A%20%22alexdenvir%40gmail.com%22%2C%22Experiment%3A%20show%20modals%20after%20joining%20league%22%3A%20false%2C%22id%22%3A%20%22Tx7TjaEsoxzPQJZ8q%22%2C%22%24email%22%3A%20%22alexdenvir%40gmail.com%22%7D; intercom-lou-n1m0idnl=1; crisp-client%2Fsession%2F11c5dc4e-49de-4a6d-bf4b-508b555583eb=session_bcb13bf2-b51c-4d9f-a2f1-68a04d8c300e; meteor_login_token=VlUSpVcIfN0Y2NotwNh7AnrXR1DTdbJrRcXMTgj2wM5",
             `Connection`= "keep-alive"),
 verbose())`

有了结果

> res
Response [https://draftfantasyfootball.co.uk/draft/HPKjiKr4QdfFiJ6qZ]
  Date: 2018-08-01 06:39
  Status: 200
  Content-Type: text/html; charset=utf-8
  Size: 11.9 kB
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" class="__meteor-css__"     href="https://d3ibm5lrns1d5x.cloudfront.net/08bc40147b8...
<meta name="fragment" content="!">
<!-- <title>Draft Fantasy Football - Premier League Fantasy Soccer (EPL/BPL/FPL)</title> -->
  <title>Draft Fantasy Football - Premier League Fantasy Football (EPL, BPL, FPL Draft & Auction)</title>
  <meta name="description" content="Draft Fantasy is the leader in fantasy sports offering free and paid DFS games. 100...

这似乎不正确,或者如果是,我不知道该怎么走?

不胜感激!

完整的请求标头:

Host: draftfantasyfootball.co.uk
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0)     Gecko/20100101 Firefox/61.0
Accept: */*
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://draftfantasyfootball.co.uk/draft/HPKjiKr4QdfFiJ6qZ
content-type: application/json
meteor-login-token: VlUSpVcIfN0Y2NotwNh7AnrXR1DTdbJrRcXMTgj2wM5
origin: https://draftfantasyfootball.co.uk
Content-Length: 2083
Cookie: ajs_user_id=%22Tx7TjaEsoxzPQJZ8q%22; ajs_group_id=null; _ga=GA1.3.722232030.1455049950; ajs_anonymous_id=%22bcfc2f78-7226-4d9b-b6c4-e2fa4f876595%22; amplitude_iddraftfantasyfootball.co.uk=eyJkZXZpY2VJZCI6IjA0NjFjM2JmLTk2NDctNGNjYS1iYmM0LTE3NTQxM2UyMmU5MSIsInVzZXJJZCI6IlR4N1RqYUVzb3h6UFFKWjhxIiwiZ2xvYmFsVXNlclByb3BlcnRpZXMiOnsiZW1haWwiOiJhbGV4ZGVudmlyQGdtYWlsLmNvbSIsIkV4cGVyaW1lbnQ6IHNob3cgbW9kYWxzIGFmdGVyIGpvaW5pbmcgbGVhZ3VlIjpmYWxzZSwiaWQiOiJUeDdUamFFc294elBRSlo4cSJ9LCJvcHRPdXQiOmZhbHNlfQ==; mp_ea7eecba53313f21feb8e49b94f188b5_mixpanel=%7B%22distinct_id%22%3A%20%22Tx7TjaEsoxzPQJZ8q%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%2C%22mp_name_tag%22%3A%20%22alexdenvir%40gmail.com%22%2C%22Experiment%3A%20show%20modals%20after%20joining%20league%22%3A%20false%2C%22id%22%3A%20%22Tx7TjaEsoxzPQJZ8q%22%2C%22%24email%22%3A%20%22alexdenvir%40gmail.com%22%7D; intercom-lou-n1m0idnl=1; crisp-client%2Fsession%2F11c5dc4e-49de-4a6d-bf4b-508b555583eb=session_bcb13bf2-b51c-4d9f-a2f1-68a04d8c300e; meteor_login_token=VlUSpVcIfN0Y2NotwNh7AnrXR1DTdbJrRcXMTgj2wM5
Connection: keep-alive

响应头:

HTTP/1.1 200 OK
Date: Wed, 01 Aug 2018 06:34:47 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: Express
Access-Control-Allow-Origin: https://draftfantasyfootball.co.uk
Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
Content-Encoding: gzip
Strict-Transport-Security: max-age=63072000
X-Frame-Options: DENY
X-Content-Type-Options: nosniff

0 个答案:

没有答案