why phantomjs code doesn't go through array?

后端 未结 1 709
一向
一向 2021-01-21 16:49

After running this code he save an infinite number of files with the source code of the first page(\"http://site1.com\"), why he doesn\'t go through other links and doesn\'t sto

1条回答
  •  旧巷少年郎
    2021-01-21 17:23

    page.evaluate() is the sandboxed page context in PhantomJS. It doesn't have access to any variable defined outside. So you cannot reference fs or page inside of it and you don't need to, because page.content is available in the outer context:

    page.open(file,function(){
        fs.write(i + '.html', page.content, 'w');
        setTimeout(next_page,100);
    });
    

    The remaining code looks fine.

    0 讨论(0)
提交回复
热议问题