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

'''

相关推荐
爬虫程序猿2 小时前
把“天猫”装进 JVM:Java 关键词商品爬虫从 0 到 1(含完整可运行代码)
java·jvm·爬虫
AI 嗯啦5 小时前
深度学习——Python 爬虫原理与实战:从入门到项目实践
爬虫·python·深度学习
深蓝电商API10 小时前
用 Selenium 搞定动态网页:模拟点击、滚动、登录全流程
爬虫·python·selenium
2501_9151063212 小时前
HTTPS 爬虫实战指南 从握手原理到反爬应对与流量抓包分析
爬虫·网络协议·ios·小程序·https·uni-app·iphone
深蓝电商API12 小时前
爬虫+Redis:如何实现分布式去重与任务队列?
redis·分布式·爬虫·python
小白学大数据21 小时前
实战:Python爬虫如何模拟登录与维持会话状态
开发语言·爬虫·python
深蓝电商API1 天前
爬虫调试技巧:如何用浏览器开发者工具找接口?
爬虫
一位代码1 天前
python | requests爬虫如何正确获取网页编码?
开发语言·爬虫·python
boss-dog1 天前
崩溃信息追溯——backward-cpp
c++·debug·backward-cpp
深蓝电商API1 天前
爬虫+Docker:让你的爬虫项目一键部署、可移植
爬虫·docker·容器