解决 The ‘more_itertools‘ package is required

在使用爬虫获取维基百科数据时看到了一个很好的项目:

博客:https://blog.51cto.com/u_15919249/5962100

项目地址:https://github.com/wjn1996/scrapy_for_zh_wiki

但在使用过程中遇到若干问题,记录一下:

The 'more_itertools' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.:

解决方案:

或许并不是环境本身的问题。

  1. pip show more_itertools没有则安装,有则下一步
  2. 把queue.py 文件及该文件中的Queue类均重命名分别为myqueue.py 与 MyQueue。
  3. 将重命名后的myqueue.py放到spiders文件夹下,
  4. 将spider下单wiki.py 中的from queue import Queue修改为from .myqueue import MyQueue
    原因可能是Python中自带queue库,而博主这里是想调用自己的queue。

后面同样要把filter_words.py文件拿到spider下,并修改wiki中的from filter_words import filter_url 为from .filter_words import filter_url

在wiki.py繁简转换中加判断,避免输入为空

'''

def Traditional2Simplified(sentence):

'''

将sentence中的繁体字转为简体字

:param sentence: 待转换的句子

:return: 将句子中繁体字转换为简体字之后的句子

'''

sentence = Converter('zh-hans').convert(sentence)

return sentence

if sentence:

sentence = Converter('zh-hans').convert(sentence)

return sentence

else:

return sentence

'''

在wiki.py中修改

'''

content_entity = search.xpath("//h1[@id='firstHeading']/text()").extract_first()

content_entity = search.xpath("//h1[@id='firstHeading']/span/text()").extract_first()

'''

相关推荐
Data_agent40 分钟前
1688获得1688店铺详情API,python请求示例
开发语言·爬虫·python
是有头发的程序猿3 小时前
如何设计一个基于类的爬虫框架
爬虫
小尘要自信8 小时前
爬虫入门与实战:从原理到实践的完整指南
爬虫
sugar椰子皮8 小时前
【爬虫框架-0】从一个真实需求说起
爬虫
月光技术杂谈11 小时前
基于Python+Selenium的淘宝商品信息智能采集实践:从浏览器控制到反爬应对
爬虫·python·selenium·自动化·web·电商·淘宝
sugar椰子皮13 小时前
【爬虫框架-2】funspider架构
爬虫·python·架构
APIshop15 小时前
用“爬虫”思路做淘宝 API 接口测试:从申请 Key 到 Python 自动化脚本
爬虫·python·自动化
xinxinhenmeihao1 天前
爬虫如何使用代理IP才能不被封号?有什么解决方案?
爬虫·网络协议·tcp/ip
2501_938810112 天前
什么IP 适用爬虫 采集相关业务
爬虫·网络协议·tcp/ip
第二只羽毛2 天前
主题爬虫采集主题新闻信息
大数据·爬虫·python·网络爬虫