【发布时间】:2013-11-15 16:07:58
【问题描述】:
我有这个结构,我需要像这样从纯文本节点获取文本
<strong><font color="#666666">Phones:</font></strong>
<br>
<br>
<img src="/image/fgh.jpg" title="Velcom" alt="Velcom" style="margin: 2 5 -3 5;">
"+375 29" //get this
<b>611 77 83</b> //and this
我尝试使用从 chrome 控制台复制的 XPath
casper.thenOpen('url', function() {
result = this.getElementInfo(x('//*[@id="main_content"]/table[2]/tbody/tr[17]/td/table/tbody/tr/td[1]/p[1]/text()[3]'));
});
casper.then(function() {
this.echo(result.text);
});
但它不起作用。另外当我尝试result.data
console.log(this.getElementInfo(x('//*[@id="main_content"]/table[2]/tbody/tr[17]/td/table/tbody/tr/td[1]/p[1]/text()[3]')));
返回null,但是页面中存在这个元素,我查了一下
【问题讨论】:
标签: javascript dom xpath phantomjs casperjs