1.设置fiddler的远程客户端代理开启
tool—>fiddlerOptions—>connections—>AllowRemote computers to connect (勾选)
2.使用nodejs的request模块进行请求
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'; // Ignore 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' authorization error
// Issue the request
request(
{
method: "GET",
uri: "https://secure.somewebsite.com/",
proxy: "http://127.0.0.1:8888" // Note the fully-qualified path to Fiddler proxy. No "https" is required, even for https connections to outside.
},
function(err, response, body) {
console.log("done");
});
3.使用superagent进行请求
var request = require('superagent');
// extend with Request#proxy()
require('superagent-proxy')(request);
// HTTP, HTTPS, or SOCKS proxy to use
// fiddler的端口默认是8888,所以这里是http://127.0.0.1:8888
var proxy = process.env.http_proxy || 'http://168.63.43.102:3128';
request
.get(process.argv[2] || 'https://encrypted.google.com/')
.proxy(proxy)
.end(onresponse);
function onresponse (err, res) {
if (err) {
console.log(err);
} else {
console.log(res.status, res.headers);
console.log(res.body);
}
}
转自:http://blog.csdn.net/wang1472jian1110/article/details/76131764