次のような HTML があります。
<html>
<body>
<table>
<tr>
Text before Text1
<td>Text1</td>
Text after Text1
</tr>
<tr>
Text before Text2
<td>Text2</td>
Text after Text2
</tr>
</table>
</body>
</html>
lxml と Python を使用しています。XPath を使用して検索Text after Text1
し、Text after Text2
XPath を試し/html/body/table/tr
て相対パスのテキストを取得しようとしましたが、と./td
しか取得できません。Text before Text1
Text before Text2
では、どうすればこれを達成できますか?
一例:
<tr>
<td width="16"><img alt="" src="http://source.qunar.com/site/images/airlines/small/HU.gif"></td>
<td valign="top">海航<span class="dc">HU7605</span><br>首都T1-虹桥/td>
</tr>
見つけられる海航
けど見つからない首都T1-虹桥
。