使用phantomjs-node收集网页上的所有链接

时间:2015-02-17 00:43:24

标签: javascript node.js phantomjs screen-scraping

我在哪里(改编自how to scrape links with phantomjs的第一个答案):

phantom.create(function (ph) {
ph.createPage(function (page) {
  page.open('http://www.' + currentSite + '.com', function (status) {
    if(status == 'success'){

      page.evaluate(function() { return [].map.call(document.querySelectorAll('a')); }, function (result) {
        console.log(result);
      });
....

但遗憾的是,结果总是为空。返回整个文档(或直接在文档上返回querySelector)会导致我的计算机挂断。

谢谢

0 个答案:

没有答案