weixin_33701251 2016-03-14 12:11 采纳率: 0%
浏览 337

PhantomJS脚本太慢

I need to get the items(with selector a[id=test]) from the page that is loaded by ajax. For this I use phantomjs.

In PHP:

$phantom_path = '/usr/bin/phantomjs';
$names  = shell_exec("$phantom_path model/phantomscript-names.js $url");

in phantomjs i received items:

var page = require('webpage').create(),
    system = require('system'),
    url = system.args[1];

page.open(url, function(status) {
    page.injectJs('jquery-2.1.4.min.js');
    var links = page.evaluate(function() {
        return [].map.call(document.querySelectorAll('a[id=test]'), function(link) {
            return link.innerText;
        });
    });
    console.log(links.join('
'));
    phantom.exit();
});

the script runs for about a minute for each page. whether it is possible to reduce this time using phantomjs or i need to use another tool for this?

  • 写回答

0条回答 默认 最新

    报告相同问题?