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

'''

相关推荐
kisloy7 小时前
【爬虫入门第13讲】Scrapy 框架深度解析(四)核心配置与自定义扩展
网络·爬虫·scrapy
TlSfoward18 小时前
TLSFoward 能帮你看到什么 TLSFOWARD抓包工具
服务器·爬虫·网络协议·https
2501_9160074718 小时前
Python实现HTTPS爬虫的完整指南:使用requests、BeautifulSoup、Selenium和Scrapy
爬虫·python·ios·小程序·https·uni-app·iphone
'pi%'19 小时前
LangGraph 多智能体实战:搭建电力政策跟踪 Agent,实现网页爬虫、OCR 与 PDF 文档自动化解析
爬虫·pdf·ocr
杨先生哦19 小时前
【2026热端攻防系列 11/12】前端AI风控攻防实战:验证码缺陷、人机验证绕过、智能爬虫对抗与企业智能风控加固方案
前端·人工智能·笔记·爬虫·安全
久久学姐19 小时前
Python开发爬虫的常用技术架构
爬虫·python·http·框架·数据存储
tang7778920 小时前
分布式爬虫优化指南:如何用代理IP把采集效率提升300%
分布式·爬虫·python·tcp/ip·分布式爬虫·爬虫代理·代理ip
二十雨辰2 天前
[爬虫]-request
爬虫
狗都不学爬虫_2 天前
AI逆向 - 99aq中心滑块验证+登录(wasm纯算)
爬虫·python·网络爬虫
hyf3266333 天前
泛程序:从零开始搭建稳定程序项目框架
运维·服务器·爬虫·百度·seo