【发布时间】:2018-02-28 10:28:42
【问题描述】:
我正在尝试在 oneblockdown.it 上使用 scrapy-spider 从最新产品中获取所有产品并将它们存储到数据库中。
我的监视器中的某些站点正在运行,但是诸如 OBD 之类的站点无法运行,并且没有将任何内容上传到数据库。这是我的功能:
class OneBlockDownSpider(Spider):
name = "OneBlockDownSpider"
allowded_domains = ["oneblockdown.it"]
start_urls = [OneBlockDownURL]
def __init__(self):
logging.critical("OneBlockDown STARTED.")
def parse(self, response):
products = Selector(response).xpath("//div[@id='product-list']")
for product in products:
item = OneBlockDownItem()
item['name'] = product.xpath('.//div[@class="catalogue-product-title"]//h3').extract.first
item['link'] = product.xpath('.//div[@class="catalogue-product-title"]//h3/a/@href').extract.first
# # item['image'] = "http:" + product.xpath("/div[@class='catalogue-product-cover']/a[@class='catalogue-product-cover-image']/img/@src").extract()[0]
# item['size'] = '**NOT SUPPORTED YET**'
yield item
yield Request(OneBlockDownURL, callback=self.parse, dont_filter=True, priority=15)
我猜我使用了错误的 xpath,但我无法解决它
【问题讨论】:
标签: python-2.7 scrapy web-crawler scrapy-spider