2017-07-05 54 views
0

嗨夥計我已經寫在python刮履帶......使用基於Python scrapy履帶但得到錯誤

import scrapy 

from c2.items import C2Item 

try: 

    class C2(scrapy.Spider): 
      name = 'cn' 
      allowed_domains = ['priceraja.com'] 
      start_urls = ['https://www.priceraja.com'] 



      def parse_item(self, response): 

       Item = [] 
       Item['url']=response.xpath('//a/@href/text()').extract() 
       yield Item 

except Exception: 
logging.exception("message") 

我不斷獲取NotImplemented錯誤

2017-08-05 01:12:28 [scrapy.core.scraper] ERROR: Spider error processing 
<GET 
https://www.killerfeatures.com> (referer: None) 
Traceback (most recent call last): 
File "D:\Ana\lib\site-packages\twisted\internet\defer.py", line 653, in _ 
runCallbacks 
current.result = callback(current.result, *args, **kw) 
File "D:\Ana\lib\site-packages\scrapy\spiders\__init__.py", line 90, in 
parse raise NotImplementedError 
NotImplementedError 
2017-08-05 01:12:28 [scrapy.core.engine] INFO: Closing spider (finished) 
2017-08-05 01:12:28 [scrapy.statscollectors] INFO: Dumping Scrapy stats: 
{'downloader/request_bytes': 435, 
'downloader/request_count': 2, 
'downloader/request_method_count/GET': 2, 

「下載/ response_bytes':9282, '下載/ response_count':2, '下載/ response_status_count/200':1, '下載/ response_status_count/301':1, 'finish_reason': '完成', 'finish_time':datetime.datetime(2017,8,4,19,42,28,837000), 'log_count/DEBUG':3, 'log_count/ERROR':1, 'log_count/INFO':7 , 'response_received_count':1, '調度器/出列':2, '調度器/出列/存儲器':, '調度器/排隊' 2:2, '調度器/入隊/存儲器':2, ' spider_exceptions/NotImplementedError':1, 'start_time':datetime.datetime(2017,8,4,19,42,25,976000)} 2017-08-05 01:12:28 [scrapy.core.engine]信息:蜘蛛關閉(完成)

+0

文件 「d:\安娜\ LIB \站點包\ scrapy \蜘蛛\ __ init__.py」,行90,在解析 提高NotImplementedError NotImplementedError 2017- 07-05 23:54:45 [scrapy.core.engine]信息:關閉蜘蛛(已完成)是我得到的錯誤 – msnegi

+0

您可以請[編輯]您的文章以包含錯誤消息,而不是將其張貼爲評論?謝謝! –

回答

1

Scrapy正在尋找解析函數,而你有impl ement parse_item函數。將parse_item更改爲解析可能會起作用,或者您可以重寫解析函數。

here另一種解決方案是使用CrawlSpider

+0

根據建議更改的代碼仍然無效。有人可以添加一個工作示例和scrapy版本 – msnegi