【发布时间】:2014-02-13 12:55:52
【问题描述】:
我正在尝试使用 python 和 Scrapy 从Subway UK Restaurant Finder 中抓取商店位置数据。我已经设法抓取了各个页面,但我想将其设置为在链接末尾运行一个包含 1000 个递归 id 的列表。任何帮助将不胜感激。
免责声明:我不知道自己在做什么
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from subway.items import SubwayFinder
class MySpider(BaseSpider):
name = "subway"
allowed_domains = ["http://www.subway.co.uk/"]
start_urls = ["http://www.subway.co.uk/business/storefinder/store-detail.aspx?id=453056039"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
titles = hxs.select("//div[@class='mid']")
items = []
for titles in titles:
item = SubwayFinder()
item ["title"] = titles.select("p/span/text()").extract()
items.append(item)
return items
【问题讨论】:
标签: python web-scraping scrapy