I need to scrape some data from website. Website have login form in which i have to logged in using node request package for scraping it. I am keep trying to login but it doesn't allow me. The code which i am using for login is :
var j = request.jar();
request = request.defaults({ jar : j })
request({
uri:url,
method:"POST",
form: {UserName:"myuser1",Password:"pass1"}
}, function (error, response, html) {
console.log("Status is : " + response.statusCode);
// console.log(response);
// console.log(html);
if (!error && response.statusCode == 302) {
console.log(html);
request.get('sub_URL', function (error, response, html) {
console.log("Inner URL status is : " + response.statusCode);
// console.log(response);
if (!error && response.statusCode == 200) {
console.log(html);
}
});
}
else{
console.log("sdfsfasdgsdfgsdfgdfghghghghdfgdfgsd");
}
});
I have seen some websites and also github references but it doesn't work. Please help me!!!
Thanks in Advance!!!!
If you are trying to run it in desktop only, I'd suggest nightmare.js or phantom.js which allows you to programmatically open login model and enter text input. The problem you might facing is:
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.