09月22日, 2014 2042次
设置FIddler 代理端口 8888
【1】php_curl
添加
$proxy="127.0.0.1:8888"; curl_setopt($ch, CURLOPT_PROXY, $proxy);
注意:最好使用php7以上版本
代码如下
function http_post_data($url, $data_string, $cookie="") { $ch = curl_init(); $proxy="127.0.0.1:8888"; curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);// 跳过证书检查,为true则从证书中检查SSL加密算法是否存在 curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded;")); ob_start(); curl_exec($ch); $return_content = ob_get_contents(); ob_end_clean(); $return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); return array($return_code, $return_content); }
【2】nodejs request 添加
proxy:'http://127.0.0.1:8888',
代码如下
url="https://mini.ems.com.cn/youzheng/orderInfo/subMailAllData"; u = { mailNo: "988xxxxxxxxxxx", openId: "xxxxxxxxxxx", service: 1, timestamp: "", sign: "", appType: 16, otherUserFlag: "" }, m = getSignData(u); var content=qs.stringify(m); var options = { method: 'post', url: url, proxy:'http://127.0.0.1:8888', rejectUnauthorized: false, body: content, headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.502', 'Referer': 'https://baidu.com' } }; request(options, function (err, res, body) { //console.log(res.statusCode) if (err) {console.log(err) }else { //fs.writeFileSync("body.txt",body); console.log(body); } })
这样请求时候就可以方便调试请求数据 !
有其他问题或者更好方法 请留言评论
暂无留言,赶快评论吧