4

When I practice, I want to catch only the text part (1,2,3,4,5...), without the part how can I write the response.css("td[class='c1']")?

scrapy shell "https://tw.movies.yahoo.com/chart.html"
response.css("td[class='c1']")

enter image description here

user2492364
  • 6,543
  • 22
  • 77
  • 147

1 Answers1

5

Here are two options, one using css(), another one using xpath():

>>> response.css("td.c1 > span::text").extract()
[u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'10', u'11', u'12', u'13', u'14', u'15', u'16', u'17', u'18', u'19', u'20']
>>> response.xpath("//td[@class='c1']/span/text()").extract()
[u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'10', u'11', u'12', u'13', u'14', u'15', u'16', u'17', u'18', u'19', u'20']
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195