div
withlistings
クラス (および)内のコンテンツid
は、XHR リクエストを介して非同期的にロードされます。つまり、Scrapy
取得する html コードにはそれが含まれていません。
$ scrapy shell http://groceries.asda.com/asda-webstore/landing/home.shtml?cmpid=ahc--ghs-d1--asdacom-dsk-_-hp#/shelf/1215337195041/1/so_false
>>> response.xpath('//div[@id="listings"]')
[]
ブラウザの開発者ツールを使用すると、リクエストがhttp://groceries.asda.com/api/items/viewitemlist url に送信され、多数の GET パラメータが指定されていることがわかります。
1 つのオプションは、そのリクエストをシミュレートし、結果の JSON を解析することです。

それを行う方法は、実際には別の質問の一部です。
selenium
パッケージを使用した解決策の 1 つを次に示します。
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://groceries.asda.com/asda-webstore/landing/home.shtml?cmpid=ahc--ghs-d1--asdacom-dsk-_-hp#/shelf/1215337195041/1/so_false')
div = driver.find_element_by_id('listings')
for item in driver.find_elements_by_xpath('//div[@id="listings"]//a[@title]'):
print item.text.strip()
driver.close()
版画:
Kellogg's Coco Pops
Kelloggs Rice Krispies
Kellogg's Coco Pops Croco Copters
...