Skip to content
Advertisement

How can I get the text clean with scrapy shell

I’m trying the following command on scrapy shell which returns this result:

In [49]: response.css('h4.team-meta__name')[1].extract()                                                                                                                 
Out[49]:h4 class="team-meta__name" style="color: #6495ED">   <strong>Ajax</strong></h4

The thing is, I want to extract only the word “Ajax” that is is between <strong> tags.

Advertisement

Answer

You need to add <strong> tag to your selector

response.css('h4.team-meta__name strong::text')[1].extract() 
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement