当Postman在请求一个超大的响应且类型是Json的时候(我们测试Json大约是 98Mb ),然后Postman就像Chrome浏览器一样,(HTTP状态码是200)无法查看响应的结果了。这样对于这类特定场景,想要看到这个超大Json,然后定位问题来说,是很不友好的。

为了在所有操作系统都支持,cURL最好的办法。只要做到将cURL的响应内容,写入到txt中即可解决。(为啥浏览器页面打印的json不能使用呢,因为过大,浏览器卡的一笔,然后无法实现复制的目的)

废话不多说,干活!

先找一个案例练手,选择 “腾讯新闻热点模块” 吧。一些小瓜娃子,真的拿我自己网站练手!别搞哦!

cURL如下:

curl --location --request POST 'https://i.news.qq.com/web_feed/getHotModuleList' \
--header 'accept: application/json, text/plain, */*' \
--header 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' \
--header 'cache-control: no-cache' \
--header 'origin: https://news.qq.com' \
--header 'pragma: no-cache' \
--header 'priority: u=1, i' \
--header 'referer: https://news.qq.com/' \
--header 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--header 'sec-fetch-dest: empty' \
--header 'sec-fetch-mode: cors' \
--header 'sec-fetch-site: same-site' \
--header 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36' \
--header 'Cookie: RK=DKtVvwsIGu; ptcz=a52b54da8cd85c924604ed886ae0f6c7f81e0a849058662ec36da841aa76f418; pgv_pvid=7505713877; _qimei_uuid42=1841b0b0a3410006bf31d1e53fb60ab44190a0a529; pac_uid=0_93b9f22df3b29; iip=0; _qimei_fingerprint=c9e4abe78f4ab85dbd304c8b937706b6; _qimei_h38=f2d24980bf31d1e53fb60ab40300000cc1841b; current-city-name=gz; _qimei_q36=; lcad_o_minduid=7W6U0OIMDDPsCYauV_5xVEunmQS0PzJd; lcad_appuser=2B048EA259E3A374; lcad_Lturn=809; lcad_LKBturn=115; lcad_LPVLturn=479; lcad_LPLFturn=782; suid=ek171418745268298274' \
--header 'content-type: application/json;charset=UTF-8' \
--data-raw '{
"qimei36": "0_93b9f22df3b29",
"base_req": {
"from": "pc"
},
"flush_num": 1,
"channel_id": "news_news_top",
"device_id": "0_93b9f22df3b29",
"item_count": 20,
"forward": "2"
}'

好的,开始尝试Mac执行这个逻辑,chatGPT是这么说的 -o filename.type

来试试吧!

curl -o /Users/zanglikun/Desktop/testCURL.txt --location --request POST 'https://i.news.qq.com/web_feed/getHotModuleList' \
--header 'accept: application/json, text/plain, */*' \
--header 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' \
--header 'cache-control: no-cache' \
--header 'origin: https://news.qq.com' \
--header 'pragma: no-cache' \
--header 'priority: u=1, i' \
--header 'referer: https://news.qq.com/' \
--header 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--header 'sec-fetch-dest: empty' \
--header 'sec-fetch-mode: cors' \
--header 'sec-fetch-site: same-site' \
--header 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36' \
--header 'Cookie: RK=DKtVvwsIGu; ptcz=a52b54da8cd85c924604ed886ae0f6c7f81e0a849058662ec36da841aa76f418; pgv_pvid=7505713877; _qimei_uuid42=1841b0b0a3410006bf31d1e53fb60ab44190a0a529; pac_uid=0_93b9f22df3b29; iip=0; _qimei_fingerprint=c9e4abe78f4ab85dbd304c8b937706b6; _qimei_h38=f2d24980bf31d1e53fb60ab40300000cc1841b; current-city-name=gz; _qimei_q36=; lcad_o_minduid=7W6U0OIMDDPsCYauV_5xVEunmQS0PzJd; lcad_appuser=2B048EA259E3A374; lcad_Lturn=809; lcad_LKBturn=115; lcad_LPVLturn=479; lcad_LPLFturn=782; suid=ek171418745268298274' \
--header 'content-type: application/json;charset=UTF-8' \
--data-raw '{
"qimei36": "0_93b9f22df3b29",
"base_req": {
"from": "pc"
},
"flush_num": 1,
"channel_id": "news_news_top",
"device_id": "0_93b9f22df3b29",
"item_count": 20,
"forward": "2"
}'

完成!

Windows终端cURL转译

开始测试Windows端!因为Windows不支持原生的curl,但是可以使用cURL导入Apifox(主要是Postman不支持Windows),然后生成新的cURL,示例如图:

curl -o C:\Users\74096\Downloads\winCurl.txt --location --request POST "https://i.news.qq.com/web_feed/getHotModuleList" ^
More? --header "pragma: no-cache" ^
More? --header "priority: u=1, i" ^
More? --header "Cookie: RK=DKtVvwsIGu; ptcz=a52b54da8cd85c924604ed886ae0f6c7f81e0a849058662ec36da841aa76f418; pgv_pvid=7505713877; _qimei_uuid42=1841b0b0a3410006bf31d1e53fb60ab44190a0a529; pac_uid=0_93b9f22df3b29; iip=0; _qimei_fingerprint=c9e4abe78f4ab85dbd304c8b937706b6; _qimei_h38=f2d24980bf31d1e53fb60ab40300000cc1841b; current-city-name=gz; _qimei_q36=; lcad_o_minduid=7W6U0OIMDDPsCYauV_5xVEunmQS0PzJd; lcad_appuser=2B048EA259E3A374; lcad_Lturn=809; lcad_LKBturn=115; lcad_LPVLturn=479; lcad_LPLFturn=782; suid=ek171418745268298274" ^
More? --header "User-Agent: Apifox/1.0.0 (https://apifox.com)" ^
More? --header "content-type: application/json;charset=UTF-8" ^
More? --data-raw "{ \"qimei36\": \"0_93b9f22df3b29\", \"base_req\": { \"from\": \"pc\" }, \"flush_num\": 1, \"channel_id\": \"news_news_top\", \"device_id\": \"0_93b9f22df3b29\", \"item_count\": 20, \"forward\": \"2\"}"
特殊说明:
上述文章均是作者实际操作后产出。烦请各位,请勿直接盗用!转载记得标注原文链接:www.zanglikun.com
第三方平台不会及时更新本文最新内容。如果发现本文资料不全,可访问本人的Java博客搜索:标题关键字。以获取最新全部资料 ❤