Twisted.internet.error.ReactorNotRestartable

时间:2017-06-27 18:47:07

标签: python-3.x scrapy

当我运行这个蜘蛛时,我得到“Twisted.internet.error.ReactorNotRestartable”。实际上,当我在项目目录中运行任何蜘蛛时,我收到此错误。我上次检查时工作正常但是从今天起它给了我这个错误。我不熟悉扭曲。请帮忙!

import scrapy
from quo.items import QuoItem
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
from twisted.internet import reactor

class ISpider(CrawlSpider):
    name='iShopE'
    handle_httpstatus_list = [400]




    def start_requests(self):
        yield scrapy.Request('https://www.ishopping.pk/electronics/home-theatres.html')

    def parse(self, response):
       for href in  response.xpath('//div[@class="category-products-"]').extract():
         for product_page in response.xpath('//h2[@class="product-name"]/a/@href').extract():
             url=response.urljoin(product_page)




             yield scrapy.Request(url, callback=self.parse_productPage)



         next_page=response.xpath('(//a[@class="next i-next"]/@href)[1]').extract()
         if next_page:
            yield scrapy.Request(response.urljoin(next_page[0]), callback=self.parse)

    def parse_productPage(self,response):
     url_ProductPage=response.url
     item=QuoItem()
     if url_ProductPage:
         item['url_ProductPage']=url_ProductPage


     for rev in response.xpath('//div[@class="product-essential"]'):





         price=response.xpath('//div[@class="price-box"]/span[@class="regular-price"]/meta[@itemprop="price"]/@content').extract()
         if price:
             item['price']=price

         newPrice=response.xpath('(//div[@class="price-box"]/p[@class="special-price"]/span[@class="price"]/text())[1]').extract()
         if  newPrice:
             newPrice=" ".join(str(x) for x in newPrice)
             newPrice=newPrice.strip('\n')
             item['price'] =newPrice.replace(" ", "")
             item['newPrice']=newPrice.replace(" ","")

         oldPrice=response.xpath('(//div[@class="price-box"]/p[@class="old-price"]/span[@class="price"]/text())[1]').extract()
         if oldPrice:
             oldPrice=" ".join(str(x) for x in oldPrice)
             oldPrice=oldPrice.strip('\n')
             item['oldPrice'] =oldPrice.replace(" ", "")



         Availability=response.xpath('//p[@class="availability in-stock"]/span[@class="value"]/text()').extract()
         if Availability:
          item['Availability']=Availability
         Brand=response.xpath('(//div[@class="box-p-attr"]/span)[1]/text()').extract()
         if Brand:
          item['Brand']=Brand
         deliveryTime=response.xpath('(//div[@class="box-p-attr"]/span)[2]/text()').extract()
         if deliveryTime:
          item['deliveryTime']=deliveryTime
         Waranty=response.xpath('(//div[@class="box-p-attr"]/span)[3]/text()').extract()
         if Waranty:
          item['Waranty']=Waranty
         title=response.xpath('//div[@class="product-name"]/h1[@itemprop="name"]/text()').extract()
         if title:
          item['Title']=title
          yield item

0 个答案:

没有答案