我正在用scrapy抓取几个网站。我的蜘蛛是不允许跨越域的。在这种情况下,重定向会使爬虫程序立即停止。在大多数情况下,我知道如何处理它,但这是一个奇怪的。在
罪魁祸首是:http://www.cantonsd.org/
我用http://www.wheregoes.com/检查了它的重定向模式,它告诉我它重定向到“/”。这将阻止spider进入其parse
函数。我该怎么办?在
编辑: 密码。在
我使用scray提供的api调用spider:http://doc.scrapy.org/en/latest/topics/practices.html#run-scrapy-from-a-script 唯一的区别是我的蜘蛛是习惯的。创建如下:
spider = DomainSimpleSpider(
start_urls = [start_url],
allowed_domains = [allowed_domain],
url_id = url_id,
cur_state = cur_state,
state_id_url_map = id_url,
allow = re.compile(r".*%s.*" % re.escape(allowed_path), re.IGNORECASE),
tags = ('a', 'area', 'frame'),
attrs = ('href', 'src'),
response_type_whitelist = [r"text/html", r"application/xhtml+xml", r"application/xml"],
state_abbr = state_abbrs[cur_state]
)
我认为问题是allowed_domains
发现{cantonsd.org
),并关闭了所有东西。在
我不报告完整的spider代码,因为它根本没有被调用,所以它不可能是问题所在。在
目前没有回答
相关问题 更多 >
编程相关推荐