我只是想與另一個網站,它在第一頁放棄由於它的問題。
這裏是日誌文件:
2015-09-29 12:28:03 [scrapy] INFO: Scrapy 1.0.3 started (bot: crawler)
2015-09-29 12:28:03 [scrapy] INFO: Optional features available: ssl, http11, boto
2015-09-29 12:28:03 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'crawler.spiders', 'SPIDER_MODULES': ['crawler.spiders'], 'REDIRECT_ENABLED': False, 'LOG_FILE': '6.4.txt', 'BOT_NAME': 'crawler'}
2015-09-29 12:28:04 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsole, LogStats, CoreStats, SpiderState
2015-09-29 12:28:05 [boto] DEBUG: Retrieving credentials from metadata server.
2015-09-29 12:28:06 [boto] ERROR: Caught exception reading instance data
Traceback (most recent call last):
File "C:\Anaconda\lib\site-packages\boto\utils.py", line 210, in retry_url
r = opener.open(req, timeout=timeout)
File "C:\Anaconda\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Anaconda\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Anaconda\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Anaconda\lib\urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Anaconda\lib\urllib2.py", line 1197, in do_open
raise URLError(err)
URLError: <urlopen error timed out>
2015-09-29 12:28:06 [boto] ERROR: Unable to read instance data, giving up
2015-09-29 12:28:06 [scrapy] INFO: Enabled downloader middlewares: HttpAuthMiddleware, DownloadTimeoutMiddleware, UserAgentMiddleware, RetryMiddleware, DefaultHeadersMiddleware, MetaRefreshMiddleware, HttpCompressionMiddleware, CookiesMiddleware, ChunkedTransferMiddleware, DownloaderStats
2015-09-29 12:28:06 [scrapy] INFO: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, UrlLengthMiddleware, DepthMiddleware
2015-09-29 12:28:06 [scrapy] INFO: Enabled item pipelines: CrawlerPipeline
2015-09-29 12:28:06 [scrapy] INFO: Spider opened
2015-09-29 12:28:06 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-09-29 12:28:06 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6023
2015-09-29 12:28:07 [scrapy] DEBUG: Crawled (301) <GET http://www.dronestory.com/> (referer: None)
2015-09-29 12:28:07 [scrapy] INFO: Closing spider (finished)
2015-09-29 12:28:07 [scrapy] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 216,
'downloader/request_count': 1,
'downloader/request_method_count/GET': 1,
'downloader/response_bytes': 471,
'downloader/response_count': 1,
'downloader/response_status_count/301': 1,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2015, 9, 29, 10, 28, 7, 774000),
'log_count/DEBUG': 3,
'log_count/ERROR': 2,
'log_count/INFO': 7,
'response_received_count': 1,
'scheduler/dequeued': 1,
'scheduler/dequeued/memory': 1,
'scheduler/enqueued': 1,
'scheduler/enqueued/memory': 1,
'start_time': datetime.datetime(2015, 9, 29, 10, 28, 6, 285000)}
2015-09-29 12:28:07 [scrapy] INFO: Spider closed (finished)
「從抄襲」當你屈服或返回回調的項目發生。如果您沒有獲得該日誌行,則您的回調沒有從30x響應中提取任何項目。檢查回調中會發生什麼情況:例如,您可以記錄每個包含狀態碼的響應URL,並檢查HTTP 301響應正文中包含的內容,如果您的scraping代碼在所有情況下均適用。 –
回調函數是蜘蛛在規則中調用的函數嗎? rules = [Rule(LinkExtractor(),process_links ='fix_links',callback ='parse_url',follow = True)] – Sebi81
對不起,我是scrapy的新手,我真的不明白它是如何工作的 當「爬行」發生時?這是否意味着該頁面正在被蜘蛛訪問?那麼爲什麼不只是從頁面上抓取數據呢?它依賴於http狀態碼嗎?我在哪裏可以看到依賴關係? – Sebi81