谷歌浏览器开发者工具系列3:拷贝cUrl重新发送请求

介绍

在网络面板中显示的网络资源可以通过点击右键菜单弹出一个上下文的菜单,然后复制这些资源并且将它们粘贴到命令行里面去。通过修改它,可以观察请求返回以及请求头的情况。

如何使用这个特性

按照以下步骤使用这个特性:
1. 网页在加载时确保网络面板已经打开了。
2. 在目标资源上右键然后选择Copy > Copy as cURL
3. 粘贴内容到终端控制台里面去。

主要作用

当这个链接包含cookie信息时,这个操作非常有用。这意味着即使你不在登录状态的界面上,也可以通过模拟请求所带的登录状态信息来获取数据,从而用于诊断或者调试的目的。

提示

在本例中,使用了iTerm2终端控制台,同时使用了Numbers API
copy as curl - 谷歌浏览器开发者工具系列3:拷贝cUrl重新发送请求

相关资源

你也可以使用Copy as Fetch选项,这样就可以在你的剪切板里面拷贝一段用来发送这个请求资源的Javascript代码。

fetch("https://www.baidu.com/sugrec?prod=pc_his&from=pc_web&json=1&sid=31253_26350&hisdata=%5B%7B%22time%22%3A1642596745%2C%22kw%22%3A%22wordpress%20google%22%7D%2C%7B%22time%22%3A1642596761%2C%22kw%22%3A%22wordpress%20%E5%BC%80%E5%90%AF%20google%20%E7%88%AC%E8%99%AB%22%7D%2C%7B%22time%22%3A1642644204%2C%22kw%22%3A%22wordpress%20image%20alt%22%7D%2C%7B%22time%22%3A1642646914%2C%22kw%22%3A%22%E5%A5%B6%E7%88%B8%E5%BB%BA%E7%AB%99%E7%AC%94%E8%AE%B0%22%7D%2C%7B%22time%22%3A1642647623%2C%22kw%22%3A%2234.7732%2C%20113.722%22%7D%2C%7B%22time%22%3A1642647702%2C%22kw%22%3A%22shadertoy%20%E6%95%99%E7%A8%8B%20part%201%20%E2%80%93%20%E4%BB%8B%E7%BB%8D%22%7D%2C%7B%22time%22%3A1642647721%2C%22kw%22%3A%22shadertoy%20%E6%95%99%E7%A8%8B%20part%201%20%E2%80%93%20%E4%BB%8B%E7%BB%8D%20%E5%8F%82%E6%95%B0%E5%BF%AB%E8%B7%91%22%7D%2C%7B%22time%22%3A1642647729%2C%22kw%22%3A%22shadertoy%20%E6%95%99%E7%A8%8B%20part%201%20%E2%80%93%20%E4%BB%8B%E7%BB%8D%20%E4%BB%93%E9%BC%A0%E5%BF%AB%E8%B7%91%22%7D%2C%7B%22time%22%3A1642647748%2C%22kw%22%3A%22%E4%BB%93%E9%BC%A0%E5%BF%AB%E8%B7%91%22%7D%2C%7B%22time%22%3A1642648158%2C%22kw%22%3A%22google%20analytics%22%7D%5D&_t=1651040278192&req=2&csor=0", {
  "headers": {
    "accept": "application/json, text/javascript, */*; q=0.01",
    "accept-language": "en,zh-CN;q=0.9,zh;q=0.8",
    "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"100\", \"Google Chrome\";v=\"100\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin"
  },
  "referrer": "https://www.baidu.com/?tn=62095104_43_oem_dg",
  "referrerPolicy": "unsafe-url",
  "body": null,
  "method": "GET",
  "mode": "cors",
  "credentials": "include"
});
发表回复 0