-1
Ich endlich geschafft, ein funktionierendes Skript zu bekommen. Nur 1 kleines Problem. Ich kann alle Seiten crawlen und alle benötigten Informationen erhalten, außer von der ersten Seite.Link Extractor in scrapy
Wo ist mein Fehler?
import scrapy.selector
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
from Prijsvergelijking.items import PrijsvergelijkingItem
class MySpider(CrawlSpider):
name = "coolblue"
allowed_domains = ["tvstore.be"]
start_urls = ["http://www.tvstore.be/category/192945/televisies.html"]
rules = (Rule(LinkExtractor(allow=(), restrict_xpaths=('//a[@class="pagination next secondary"]',)), callback = "parse_items",follow = True),)
def parse_items(self, response):
products = response.xpath("//li[@class='product-list-columns--item product-list-item']")
for product in products:
item = PrijsvergelijkingItem()
item["Product_ref"] = product.xpath(".//h2/a/text()").extract_first().strip()
item["Product_price"] = product.xpath(".//strong[1]/text()").extract_first().strip().replace(",",".").replace("-","")
yield item