dryleaf
dryleaf

Reputation: 423

Using css selector to extract text outside of span in scrapy crawling

I have the following html code:

    <h1>
        <a href="https://www.google.com">
            <span>448587: </span>Brian McMills
        </a>
    </h1>

I'm only interested in Brian McMills. I would like to use scrapy css selector function to select the text.

When I use h1 a ::text, it selects only the 448587: portion, I tried some combinations of :not(span) but it doesn't work.

Note: I'm not interested in Xpath or scripting solutions, only css.

Upvotes: 1

Views: 1980

Answers (1)

dryleaf
dryleaf

Reputation: 423

The only thing that worked was h1 a:not(span)::text.

Thanks.

Upvotes: 1

Related Questions