问题
I am trying to scrap a page : http://fd1-www.leclercdrive.fr/057701/courses/pgeWMEL009_Courses.aspx#RS284323
But as you can see this link redirect to fd1-www.leclercdrive.fr/057701/courses/pgeWMEL009_Courses.aspx when you first access it. after you click on "fruits et légumes" you can access the page using the url directly
So I need to simulate a click on the button "Fruits et légumes" to access the page I want. In the code, it does a dopostback
Here is my code that I use with casperj
s :
var casper = require('casper').create({
verbose: true,
logLevel: "debug"
});
casper.start('http://fd1-www.leclercdrive.fr/057701/courses/pgeWMEL009_Courses.aspx#RS284323');
// here i simulate the click on "Fruits et légumes"
casper.evaluate(function() {
__doPostBack('objLienReceptdionEvenement','2@@284323');
});
casper.then(function() {
console.log(' new location is ' + this.getCurrentUrl());
});
casper.run();
I still be redirected to the wrong page
回答1:
The call to __doPostBack is not correct (extra 'd' in 'objLienReceptdionEvenement'
)
Should be
// here i simulate the click on "Fruits et légumes"
casper.evaluate(function() {
__doPostBack('objLienReceptionEvenement','2@@284323');
})
来源:https://stackoverflow.com/questions/17830597/casperjs-how-to-call-dopostback