web-scrapingxpathscrapyscrapy-shell

Scrapy Amazon absolute path but with no value returned


I am trying to use Scrapy some info from amazon.co.uk by using absolute path as below. but strangely no value returned. I am quite new to Scrapy:

scrapy shell http://www.amazon.co.uk/product-reviews/B0042EU3A2/

response.xpath('//*[@id="productReviews"]/tbody/tr/td[1]/a[1]/@name').extract()

I would like it to return name attribute in this case is: RI4HGFJCSI04W.


Solution

  • Just omit the tbody from the expression:

    In [1]: response.xpath('//*[@id="productReviews"]//tr/td[1]/a[1]/@name').extract()
    Out[1]: [u'RI4HGFJCSI04W']