When I try to execute the code with nodejs , it immediately gives error and not even process to execute the url with proxy, but when I remove the proxy option it works. Following is my code for hitting any Url using proxy:
request({
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept-Language': 'en-US,en;q=0.5',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36',
// 'Cookie': cookieReq
},
uri: 'www.website.com',
method: 'GET',
proxy: 192.12.31.12:3128
}, function (error, response, html) {
if (!error && response.statusCode == 200) {
// final operations
fs.writeFile('eight.html', html, function(err) {
if (err) {
return console.error(err);
}
});
}
});
Try
proxy: "http://192.12.31.12:3128"
instead of
proxy: 192.12.31.12:3128
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.