CasperJS loop or iterate through multiple web pages?

前端 未结 3 1647
难免孤独
难免孤独 2020-12-05 01:20

I have a CasperJS script that scrapes ratings and dates from one webpage. Now I want to scrape the same data from multiple pages under the same website. How can I loop throu

3条回答
  •  孤城傲影
    2020-12-05 01:43

    Since there exists a next page button, you can use it to traverse all pages recursively:

    function getRatingsAndWrite(){
        ratings = casper.evaluate(getRatings);
        dates = casper.evaluate(getDate);
    
        casper.echo(ratings);
        casper.echo(ratings.length + ' ratings found:');
    
        for(var i=0; i

    A related answer is A: CasperJS parse next page after button click.

提交回复
热议问题