CasperJS : how to call __doPostBack

混江龙づ霸主 提交于 2019-12-11 08:26:03

问题


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:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!