Scrapy get all text including children

I have a series of <p> elements inside a document that I am scraping with scrapy.
some of them: <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 children (suppose I already have a <p selector)
(second example: have the string bla bla bla second bla bla )

+5
source share
1 answer

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

eg:

 .//p//text() 
+6
source

Source: https://habr.com/ru/post/1205507/


All Articles