Reputation: 925
I am trying to scrap this website https://www.erobertparker.com/entrance.aspx it requires authentication I am using request module to get authenticated like this,
request({
url:"https://www.erobertparker.com/login.aspx",
method:"POST",
form:{UNENTRY:"username",PWENTRY:"password"}
},
function(error,response,body){
})
but i am unable to get authenticated what i am doing wrong can someone please guide me I am new to web scraping world :).
Upvotes: 3
Views: 11269
Reputation: 9
Hi I solved this using a jar parameter in the request:
var j = request.jar();
var request = request.defaults({ jar : j }) //it will make the session default for every request
//...
request({
url:"https://www.erobertparker.com/login.aspx",
method:"POST",
form:{UNENTRY:"username",PWENTRY:"password"}
},
function(error,response,body){
//Do your logic here or even another request like
request({
url:"<ANOTHER LINK>",
method:"GET",
}, function(error, response, body){
//Some logic
});
});
You can also check the documentation of the request module: https://github.com/request/request#examples
Upvotes: 0
Reputation: 5385
It's using an asp.net session cookie. You possibly need to store all cookies in a jar and then send them back on the next request.
Upvotes: 1