请看下面的链接
http://finance.yahoo.com/q/op?s=C
我需要获得这一行文字
View By Expiration: Sep 10 | Oct 10 | Dec 10 | Jan 11 | Mar 11 | Jan 12
其中的
Sep 10 | Oct 10 | Dec 10 | Jan 11 | Mar 11 | Jan 12
于是我用firebug,看了一下,
/html/body/div/div[3]/table[2]/tbody/tr[2]/td/
这样表达不行,会得到许多其他的东西,请问,如何写这个xpath表达式?
http://finance.yahoo.com/q/op?s=C
我需要获得这一行文字
View By Expiration: Sep 10 | Oct 10 | Dec 10 | Jan 11 | Mar 11 | Jan 12
其中的
Sep 10 | Oct 10 | Dec 10 | Jan 11 | Mar 11 | Jan 12
于是我用firebug,看了一下,
/html/body/div/div[3]/table[2]/tbody/tr[2]/td/
这样表达不行,会得到许多其他的东西,请问,如何写这个xpath表达式?
| <a href="http://finance.yahoo.com/q/op?s=C&m=2010-10">Oct 10</a>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2010-12">Dec 10</a>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2011-01">Jan 11</a>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2011-03">Mar 11</a>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2012-01">Jan 12</a>
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td height="2"></td></tr></tbody></table>
<table class="yfnc_mod_table_title1" width="100%" border="0" cellpadding="2" cellspacing="0"><tbody><tr valign="top">
这里的内容省略
</table>
</td>
我用xpath到达<td>后,如何获得里面的<strong>Sep 10</strong>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2010-10">Oct 10</a>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2010-12">Dec 10</a>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2011-01">Jan 11</a>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2011-03">Mar 11</a>
| <a href="http://finance.yahoo.com/q/op?s=C&m=2012-01">Jan 12</a>
<table>
<tr>
<td>ok
<strong>Sep 10</strong>
| <a href="ttt">Oct 10</a>
| <a href="kkk">Dec 10</a>
<table>
<tr>
<td>
123
</td>
<td>
567
</td>
</tr>
</table>
</td>
</tr>
</table>
我用firefox打开如下:
ok Sep 10 | Oct 10 | Dec 10
123 567
如果,我这样写表达式
xpath('/html/body/table/tr/td')
获得输出
<td>ok
<strong>Sep 10</strong>
| <a href="ttt">Oct 10</a>
| <a href="kkk">Dec 10</a>
<table><tr>
<td>
123
</td>
<td>
567
</td>
</tr></table>
</td>
我需要的结果是:
ok
<strong>Sep 10</strong>
| <a href="ttt">Oct 10</a>
| <a href="kkk">Dec 10</a>
请问,如何写表达式?