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?