我是scrapy的新手,它是我知道的惊人的爬虫框架!
在我的项目中,我发送了超过90,000个请求,但其中一些请求失败了.我将日志级别设置为INFO,我只能看到一些统计信息,但没有详细信息.
2012-12-05 21:03:04+0800 [pd_spider] INFO: Dumping spider stats:
{'downloader/exception_count': 1,
'downloader/exception_type_count/twisted.internet.error.ConnectionDone': 1,
'downloader/request_bytes': 46282582,
'downloader/request_count': 92383,
'downloader/request_method_count/GET': 92383,
'downloader/response_bytes': 123766459,
'downloader/response_count': 92382,
'downloader/response_status_count/200': 92382,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2012, 12, 5, 13, 3, 4, 836000),
'item_scraped_count': 46191,
'request_depth_max': 1,
'scheduler/memory_enqueued': 92383,
'start_time': datetime.datetime(2012, 12, 5, 12, 23, 25, 427000)}
Run Code Online (Sandbox Code Playgroud)
有没有办法获得更多细节报告?例如,显示那些失败的URL.谢谢!
我正在使用scrapy来抓取我的站点地图,检查404,302和200页.但我似乎无法获得响应代码.到目前为止这是我的代码:
from scrapy.contrib.spiders import SitemapSpider
class TothegoSitemapHomesSpider(SitemapSpider):
name ='tothego_homes_spider'
## robe che ci servono per tothego ##
sitemap_urls = []
ok_log_file = '/opt/Workspace/myapp/crawler/valid_output/ok_homes'
bad_log_file = '/opt/Workspace/myapp/crawler/bad_homes'
fourohfour = '/opt/Workspace/myapp/crawler/404/404_homes'
def __init__(self, **kwargs):
SitemapSpider.__init__(self)
if len(kwargs) > 1:
if 'domain' in kwargs:
self.sitemap_urls = ['http://url_to_sitemap%s/sitemap.xml' % kwargs['domain']]
if 'country' in kwargs:
self.ok_log_file += "_%s.txt" % kwargs['country']
self.bad_log_file += "_%s.txt" % kwargs['country']
self.fourohfour += "_%s.txt" % kwargs['country']
else:
print "USAGE: scrapy [crawler_name] -a country=[country] -a domain=[domain] \nWith [crawler_name]:\n- tothego_homes_spider\n- tothego_cars_spider\n- tothego_jobs_spider\n"
exit(1) …Run Code Online (Sandbox Code Playgroud) 有些网站暂时出现404错误.但我粘贴在浏览器上它可以工作.如何告诉scrapy重试404状态代码链接5次.
我正在使用scrapy来抓取超过400万种产品的产品网站。然而,在抓取大约 50k 产品后,它开始抛出 500 HTTP 错误。我已将 Auto throttling 设置为 false ,因为在启用其非常慢后,将需要大约 20-25 天才能完成抓取。我认为服务器在一段时间后开始暂时阻止爬虫。任何解决方案可以做什么?我正在使用站点地图爬虫 - 如果服务器没有响应,我想从 url 本身提取一些信息并继续下一个 url 而不是完成爬行并关闭蜘蛛,为此我正在查看请求中的 errback 参数。但是,由于我使用的是站点地图爬虫,因此我没有明确创建请求对象。是否有任何我可以覆盖的默认 errback 函数或者我可以在哪里定义它。