0
我從網站上刮取足球比分數據。所有比分都在一張桌子上,每個<tr>
都有「封鎖主場比賽17」和一些獨特的東西。CasperJS'getElementsByXpath返回null與有效的XPath
我在Chrome開發工具中測試了我的xpath,它只識別我需要的錶行。
var utils = require('utils');
var casper = require('casper').create();
var xpath = require('casper').selectXPath;
var result = [];
function getScores(){
console.log("getting scores");
result = __utils__.getElementsByXPath("//tr[contains(@id,'block_home_matches_17')");
}
casper.start('http://int.soccerway.com/', function() {
console.log("casper start....");
var l = getScores();
utils.dump(l);
});
casper.run();
該代碼返回[] as utils.dump!爲什麼?我的xpath是有效的!
有關? http://stackoverflow.com/questions/3655549/xpath-containstext-some-string-doesnt-work-when-used-with-node-with-more –