【发布时间】:2021-10-21 06:29:50
【问题描述】:
您好,我一直在尝试将 div - p 标签中的所有文本部分添加到 hr 标签,所以有人给了这个 xpath
//div[@class="entry"]/*[not(preceding-sibling::hr | self::hr)]/text()
可以正常工作,但这会忽略 p 标签中 <.a> 标记中的文本部分 有什么想法可以获取该文本吗?
<div class="entry">
<p> some text</p>
<p> some text2</p>
<p> some text3</p>
<p> some text4
<a href='somelink'> this text here i want to get through xpath</a>
some text5
</p>
<hr>(up to this hr tag)
<p> some text5</p>
<hr>
<p> some text6</p>
</div>
【问题讨论】:
标签: html web-scraping xpath scrapy