Scrapy css selector: get text of all inner tags

Get text of only selected node.

response.css('mytag::text')

Get text of selected node and its child nodes.

response.css('mytag ::text')

See the difference between these two versions. The only difference is the space. If there is no space then only text/attributes of current nodes are returned. If there is space then it selects text/attributes of self and child nodes

response.css('h1 a::attr(href)') # only current node attribute

response.css('h1 ::attr(href)') # current node and all child nodes attribute.

response.css('mytag *::text')

The * will visit all the inner tags of mytag and ::text will get the text of each of them

Tags:

Html

Css

Scrapy