2017-07-31 15 views
0

属性が見つからないと、私はオンラインで見つける修正したテンプレートは、私は次のエラーを取得しています:Scrapy CrawlSpiderはScrapy 1.4.0使用

AttributeError: module 'scrapy' has no attribute 'CrawlSpider'

は、ログは興味の何かを表示するには表示されません。

コード:

import scrapy 
from scrapy.spiders import Rule 
from scrapy.linkextractors import LinkExtractor 

class TechcrunchSpider(scrapy.CrawlSpider): 
    #name of the spider 
    name = 'stltoday' 

    #list of allowed domains 
    allowed_domains = ['http://graphics.stltoday.com/'] 

    #starting url for scraping 
    start_urls = ['http://graphics.stltoday.com/apps/payrolls/salaries/2_1/'] 

    rules = [ 
    Rule(LinkExtractor(
     allow=['/apps/payrolls/salaries/.*/$']), 
     callback='parse', 
     follow=True), 
    ] 

    #setting the location of the output csv file 
    custom_settings = { 
     'FEED_URI' : 'tmp/stltoday.csv' 
    } 

    def parse(self, response): 
     #Remove XML namespaces 
     response.selector.remove_namespaces() 

     #Extract article information 
     name = response.xpath("//th::text").extract() 
     allother = response.xpath('//table[@class="table--department"]//td').extract() 


     for item in zip(name,allother): 
      scraped_info = { 
       'name' : item[0], 
       'allother' : item[1] 
      } 

      yield scraped_info 
+1

[1.4.0ドキュメント](https://doc.scrapy.org/en/latest/topics/spiders.html)によると、それは 'scrapy.spiders.CrawlSpider'です。 –

答えて

1

というエラーがモジュールscrapyCrawlSpiderクラスが含まれていないことを意味します。コメントに記載されているように、これは治療のための文書の変更の結果です。クイックフィックスは

問題を解決する必要があり
class TechcrunchSpider(scrapy.spiders.CrawlSpider): 

class TechcrunchSpider(scrapy.CrawlSpider): 

を変更する必要があります!