scrapy get the entire text including children

大城市里の小女人 提交于 2019-12-21 12:10:15

问题


I have a series of <p> elements inside a document I'm scraping with scrapy.
some of the are: <p><span>bla bla bla</span></p> or <p><span><span>bla bla bla</span><span>second bla bla</span></span></p>

I want to extract all the text with the children (assume I already have the selector of the <p)
(second example: to have a string bla bla bla second bla bla)


回答1:


you can just use //text() to extract all text from children nodes

for example:

.//p//text()


来源:https://stackoverflow.com/questions/26564843/scrapy-get-the-entire-text-including-children

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!