CasperJS : how to call __doPostBack

2019-08-03 23:24发布

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 casperjs :

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条回答
等我变得足够好
2楼-- · 2019-08-03 23:55

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');
})
查看更多
登录 后发表回答