Armen Sanoyan
Armen Sanoyan

Reputation: 2042

Get child of selector in Scrapy

I have a selector which I got from filtering list of selectors. Now I need to get the child of this selector. The code for getting list of selectors is

results = response.css('font::text, b::text, p::text, span::text').getall()
    for r in results:
        if 'some_charecters' in r.root:
            result = r
            

Now My goal is to get the child of result selector. Which is the best way to get it? I have tried to find a function like get_child, but seems like there is no a build in functions for this kind of purposes.

Upvotes: 0

Views: 944

Answers (1)

Thiago Curvelo
Thiago Curvelo

Reputation: 3740

results = response.css('font::text, b::text, p::text, span::text')
for r in results:
   # ... filter it as you want ...        
   children = r.xpath("./*")

Upvotes: 2

Related Questions