Web scraping with casperjs returns error

46 Views Asked by At

I am trying to scrape a website using the casperjs library. I am not able to get it to progress past a certain page, as it constantly redirects and loops back to the page I am on, despite correctly entering for the form.

casper.then(function(){
    // skipped for brevity
    // form details entered

    this.click("#login-button"); // submit form with input button
}

and then when I go the next main login page:

casper.then(function(){
    capture(); // capture screenshot
}

all it returns is the page I am still currently on. What is going on?

1

There are 1 best solutions below

3
On

The click function in casperjs doesn't use that sort of selector, but instead uses new CSS3 ones. You said that the form was an input element? If that's the case then you can use the selector input[id='login-button'] instead.

casper.then(function(){
    // skipped for brevity
    // form details entered

    this.click("input[id='login-button']"); // submit form with input button
}