0

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.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

1 Answers1

0

You need to add <strong> tag to your selector

response.css('h4.team-meta__name strong::text')[1].extract() 
Georgiy
  • 3,158
  • 1
  • 6
  • 18
  • Thank you very much Sir :) it works! can you explain why there is no "." between name and strong ? – Aurelio Mesquita Mar 05 '19 at 17:00
  • We use `.` in css selectors when we need to select elements by `class` attribute. In this case `strong` is tag name. css selector looks for text inside `strong` tag inside `h4` tag with `team-meta__name` class – Georgiy Mar 05 '19 at 17:06
  • Sorry to bother you again, but is It possible to when we extract the data in to a csv file, we save It into a table? If so can you give me an example? – Aurelio Mesquita Mar 05 '19 at 23:30