我正在为我的校报写一个应用程序,它完全是通过wordpress在线运行的。我正在使用Hpple来解析html。来自以下内容:
</div>
<div id="fs-2" class="fs">
<div id="fsh-2" class="fsh">
<div id="fdh-2" class="fdh"><a href="http://www.mabearnews.com/entertainment/2012/12/26/hit-or-mis-les-miserables-review/">Hit or ‘Mis’: Les Miserables Review<br> by *******</a></div>
<a href="http://www.mabearnews.com/entertainment/2012/12/26/hit-or-mis-les-miserables-review/"><img src="http://www.mabearnews.com/wp-content/uploads/2012/12/les-miserables-2012-wallpapers-les-miserables-2012-movie-32697313-1280-800-600x375.jpg" id="fph-2" class="fph" /></a>哪个xpath查询字符串将返回图像url (img src)?
发布于 2012-12-31 11:35:29
html内容的格式不正确。
假设这是正确的html内容:
<div id="fs-2" class="fs">
<div id="fsh-2" class="fsh">
<div id="fdh-2" class="fdh"><a href="http://www.mabearnews.com/entertainment/2012/12/26/hit-or-mis-les-miserables-review/">Hit or ‘Mis’: Les Miserables Review<br> by *******</a></div>
<a href="http://www.mabearnews.com/entertainment/2012/12/26/hit-or-mis-les-miserables-review/"><img src="http://www.mabearnews.com/wp-content/uploads/2012/12/les-miserables-2012-wallpapers-les-miserables-2012-movie-32697313-1280-800-600x375.jpg" id="fph-2" class="fph" /></a>
</div>
</div>您可以使用以下xpath查询获取图像URL:
//div[@id="fsh-2"]/a/img/@srchttps://stackoverflow.com/questions/14097097
复制相似问题