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

'''

相关推荐
用户1997010801815 小时前
深入研究:Shopee商品详情API接口详解
大数据·爬虫·数据挖掘
攻城狮7号17 小时前
Python爬虫第18节-动态渲染页面抓取之Splash使用上篇
开发语言·人工智能·爬虫·python·python爬虫
像风一样自由202017 小时前
从零开始构建微博爬虫与数据分析系统
爬虫·python
memorycx1 天前
爬虫(requests库,logging库)
爬虫
yuanlaile1 天前
AI写代码之GO+Python写个爬虫系统
爬虫·python·go·ai编程
愚公搬代码1 天前
【愚公系列】《Python网络爬虫从入门到精通》057-分布式爬取中文日报新闻数据
分布式·爬虫·python
亿牛云爬虫专家1 天前
GraphQL接口采集:自动化发现和提取隐藏数据字段
爬虫·爬虫代理·graphql·代理ip·yelp·采集·数字字段
愚公搬代码1 天前
【愚公系列】《Python网络爬虫从入门到精通》063-项目实战电商数据侦探(主窗体的数据展示)
开发语言·爬虫·python
摸爬滚打的小李2 天前
关于禁用 javaScript
debug
攻城狮7号2 天前
Python爬虫第16节-动态渲染页面抓取之Selenium使用上篇
爬虫·python·python爬虫