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

'''

相关推荐
Bright Data6 小时前
DuckDuckGo 搜索爬取器
爬虫·serp·网页数据
去码头整点薯条ing11 小时前
某当网登录滑块【协议+OCR】
爬虫·python·ocr
上海云盾-小余11 小时前
中小站点防护避坑:低价高防服务存在的各类安全短板剖析
网络·爬虫·安全·ddos
阿标在干嘛15 小时前
从单机到分布式:政策快报爬虫系统的三次重构
分布式·爬虫·重构
2401_8734794017 小时前
爬虫IP怎么防?IP离线库四层识别+日志留存,反爬留证两不误
爬虫·网络协议·tcp/ip·ip
胡耀超2 天前
从一次批量爬取到生产同步:问题变了,建设边界也要跟着变
爬虫·python·系统架构·数据治理·数据同步·接口设计·爬虫工程
TlSfoward2 天前
TLSFOWARD TLS指纹
开发语言·数据库·爬虫·搜索引擎·https·php
深蓝电商API2 天前
浏览器一次请求到底经历了什么?
爬虫
oh,huoyuyan3 天前
火车采集器同时运行超多任务运行优化方案
爬虫·火车采集器
TlSfoward4 天前
爬虫指纹漂移监控与回归测试:JA3/JA4 变化为什么会影响线上验证 TLSFOWARD
数据库·爬虫·网络协议·搜索引擎