在 Chrome DevTools 的 Network 部分下,右键单击您感兴趣的行并选择从上下文菜单中选择合适的副本:
剪贴板内容示例如下所示:
复制为 cURL
curl 'https://stackoverflow.com/posts/25291052/editor-heartbeat/answer' \
-H 'authority: stackoverflow.com' \
-H 'pragma: no-cache' \
-H 'cache-control: no-cache' \
-H 'sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"' \
-H 'accept: application/json, text/javascript, */*; q=0.01' \
-H 'x-requested-with: XMLHttpRequest' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36' \
-H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'origin: https://stackoverflow.com' \
-H 'sec-fetch-site: same-origin' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-dest: empty' \
-H 'referer: https://stackoverflow.com/questions/25291052/how-to-view-the-whole-raw-http-request' \
-H 'accept-language: en,pl;q=0.9,es;q=0.8' \
-H 'cookie: prov=8a6c8983-02cd-669c-367d-61ff657f111e; _ga=GA1.2.1494864357.1594965293; __qca=P0-618917173-1594965293194; __gads=ID=86eda01ab828f223:T=1594965534:R:S=ALNI_MZ6mV2_oJewkg2Z7wubZCCK_dFI0Q; gadsTest=test; sgt=id=9653ade3-9325-4178-a074-d2ff62012690; _gid=GA1.2.480664929.1621240994; acct=t=PYE1PDFUezJZN%2b7eJHz4uQtgdkSgmrsw&s=NfLIf8YH%2f3FPmxGoaPDa2w5sB%2bzihVsv' \
--data-raw 'fkey=39c9ef4d76e1af44087482fe5f9802ac518ce9725a5323015874a7e69a493dea&clientCount=4' \
--compressed
复制为抓取
fetch("https://stackoverflow.com/posts/25291052/editor-heartbeat/answer", {
"headers": {
"accept": "application/json, text/javascript, */*; q=0.01",
"accept-language": "en,pl;q=0.9,es;q=0.8",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"pragma": "no-cache",
"sec-ch-ua": "\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\"",
"sec-ch-ua-mobile": "?0",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest"
},
"referrer": "https://stackoverflow.com/questions/25291052/how-to-view-the-whole-raw-http-request",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": "fkey=39c9ef4d76e1af44087482fe5f9802ac518ce9725a5323015874a7e69a493dea&clientCount=4",
"method": "POST",
"mode": "cors",
"credentials": "include"
});
我们还可以选择使用“全部复制为...”之一来检索特定的响应或列表中的所有请求 选项。
亲自尝试并选择最适合您的选项。
This 网站启发了我的回答。