解决 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()

'''

相关推荐
bugtraq202112 小时前
闲鱼网页版开放,爬虫的难度指数级降低。
爬虫
Bigcrab__16 小时前
Python3网络爬虫开发实战(15)Scrapy 框架的使用(第一版)
爬虫·python·scrapy
九月镇灵将16 小时前
爬虫逆向学习(六):补环境过某数四代
爬虫·补环境·瑞数
kngines17 小时前
【PLW004】基于Python网络爬虫与推荐算法的新闻推荐平台v1.0(Python+Django+NLP+Vue+MySQL前后端分离)
爬虫·python·nlp·推荐算法
walk walk1 天前
免费爬虫软件“HyperlinkCollector超链采集器v0.1”
爬虫
亿牛云爬虫专家1 天前
如何通过subprocess在数据采集中执行外部命令 —以微博为例
爬虫·python·数据采集·多线程·代理ip·subprocess·微博
菜鸡中的奋斗鸡→挣扎鸡1 天前
初始爬虫5
爬虫
无敌开心1 天前
Django-Celery-Flower实现异步和定时爬虫及其监控邮件告警
爬虫·python·django