python2.7 BeautifulSoup 模块 报错
Posted rab3it
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python2.7 BeautifulSoup 模块 报错相关的知识,希望对你有一定的参考价值。
运行python文件,发现 BeautifulSoup 模块 报错
Traceback (most recent call last):
File "xxx.py", line 10, in <module>
from bs4 import BeautifulSoup
File "/Library/Python/2.7/site-packages/bs4/__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "/Library/Python/2.7/site-packages/bs4/builder/__init__.py", line 4, in <module>
from bs4.element import (
File "/Library/Python/2.7/site-packages/bs4/element.py", line 5, in <module>
from bs4.dammit import EntitySubstitution
File "/Library/Python/2.7/site-packages/bs4/dammit.py", line 50, in <module>
class EntitySubstitution(object):
File "/Library/Python/2.7/site-packages/bs4/dammit.py", line 71, in EntitySubstitution
CHARACTER_TO_HTML_ENTITY_RE) = _populate_class_variables()
File "/Library/Python/2.7/site-packages/bs4/dammit.py", line 59, in _populate_class_variables
character = chr(codepoint)
ValueError: chr() arg not in range(256)
原理没搞懂,只知道 更新就可以??
更新 beautifulsoup4 模块
pip install --upgrade beautifulsoup4
没有这个模块需要重新安装
pip install bs4
以上是关于python2.7 BeautifulSoup 模块 报错的主要内容,如果未能解决你的问题,请参考以下文章
[Python2.7] [爬虫] [BeautifulSoup],如图,使用soup.find()查找到目标后,怎样提取其中的content?