【发布时间】:2015-10-26 05:38:41
【问题描述】:
我已经在 python 中实现了一个小爬虫,我想尝试在弹性搜索中导出结果,如tutorial 中所述。
由于 scrapy 插件的 elasticsearch 更新(参见 github link),我已在评论中提出修复建议。我已经用刮板中的现有字段更改了 ELASTICSEARCH_UNIQ_KEY。当然,我已经安装了插件并检查了我的蜘蛛是否正常工作(我已经成功地在 json 中输出命令 scrapy crawl brand -o output.json 其中品牌是我的蜘蛛的名称)
我已经安装了 elasticsearch 并且它正在运行,我已经能够重现在 here 找到的一些示例。但是当我使用以下命令时它不起作用:scrapy crawl brand。
我在 settings.py 文件的 ELASTICSEARCH_LOG_LEVEL= 'log.DEBUG' 行中添加了引号,因为没有它就无法识别日志。但是现在,我有以下错误:
Traceback (most recent call last):
File "C:\Users\stephanie\Downloads\WinPython-32bit-2.7.9.2\python-2.7.9\lib\site-packages\twisted\internet\defer.py", line 588, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "C:\Users\stephanie\Downloads\WinPython-32bit-2.7.9.2\python-2.7.9\lib\site-packages\scrapyelasticsearch\scrapyelasticsearch.py", line 70, in process_item
self.index_item(item)
File "C:\Users\stephanie\Downloads\WinPython-32bit-2.7.9.2\python-2.7.9\lib\site-packages\scrapyelasticsearch\scrapyelasticsearch.py", line 53, in index_item
log.msg("Generated unique key %s" % local_id, level=self.settings.get('ELASTICSEARCH_LOG_LEVEL'))
File "C:\Users\stephanie\Downloads\WinPython-32bit-2.7.9.2\python-2.7.9\lib\site-packages\scrapy\log.py", line 49, in msg
logger.log(level, message, *[kw] if kw else [])
File "C:\Users\stephanie\Downloads\WinPython-32bit-2.7.9.2\python-2.7.9\lib\logging\__init__.py", line 1220, in log
raise TypeError("level must be an integer")
TypeError: level must be an integer
2015-08-04 02:06:02 [scrapy] INFO: Crawled 1 pages (at 1 pages/min), scraped 0 items (at 0 items/min)
2015-08-04 02:06:02 [scrapy] INFO: Closing spider (finished)
2015-08-04 02:06:02 [selenium.webdriver.remote.remote_connection] DEBUG: DELETE
http://127.0.0.1:49654/hub/session/209677e4-1577-4f05-a418-8554159d8c74/window {
"sessionId": "209677e4-1577-4f05-a418-8554159d8c74"}
2015-08-04 02:06:03 [selenium.webdriver.remote.remote_connection] DEBUG: Finished Request
2015-08-04 02:06:03 [scrapy] INFO: Dumping Scrapy stats:
我正在使用 python 2.7 和 elasticsearch 1.7.1 我是否必须使用弹性搜索进行一些配置或可能导致此错误的原因?感谢您的帮助。
【问题讨论】:
标签: python selenium elasticsearch web-scraping scrapy