一、從charles等抓包工具中請求地址復制為CURL粘貼至postman可直接生成接口請求
操作:1、如下圖右鍵->復制cURL Request
復制后代碼示例:
curl -H
'Host: www.baidu.com'
-H
'user-agent: Android Phone 22 com.hfjy.learningparentphone 2.0.5'
-H
'uuid: 234795ca-ee25-5a2a-6384-1492fefaff6d'
-H
'x-hf-learn-session-id: 5puvyxjzs8m87n7b7k34'
-H
'content-type: application/x-www-form-urlencoded'
--data-binary
"version=68&platformType=2"
//請求格式--compressed 'https://www.baidu.com'
|
2、導入postman
二、從chrome等瀏覽器中請求地址復制為CURL粘貼至postman可直接生成接口請求
復制后代碼示例:
curl 'https://recomm.cnblogs.com/api/v2/recomm/blogpost/reco' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: https://www.cnblogs.com/' -H 'Origin: https://www.cnblogs.com' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36' -H 'Content-Type: application/json; charset=UTF-8' --data-binary '{"itemId":10920841,"itemTitle":"Charles mock數據方法"}' --compressed
導入postman方法參照charles
三、詳細cURL規則
curl的一般格式curl <一個url>
- 用curl -X POST \請求地址\ 指定request請求方式
- 用-H 'key=value'指定header鍵值對
- 用--data-binary '{"key":"value"}' ——application/json
- 用--data-binary ”version=68&platformType=2“——application/Text
- 用-d ”version=68&platformType=2“——application/x-www-form-urlencoded