1.ImportError: No module named BeautifulSoup       

当你成功安装BeautifulSoup 4库后,“from BeautifulSoup import BeautifulSoup”可能会遇到该错误。

安装beautifulsoup库时遇到麻烦
安装beautifulsoup库时遇到麻烦
        其中的原因是BeautifulSoup 4库改名为bs4,需要使用“from bs4 import BeautifulSoup”导入。

        2.TypeError: an integer is required

        当你使用“print soup.title.string”获取title的值时,可能会遇到该错误。如下:
安装beautifulsoup库时遇到麻烦
        它应该是IDLE的BUG,当使用命令行Command没有任何错误。参考:stackoverflow。同时可以通过下面的代码解决该问题:
        print unicode(soup.title.string)
        print str(soup.title.string)

下载地址:https://www.crummy.com/software/BeautifulSoup/bs4/download/

下载完成后解压到python安装包的地方,存放在Beautifulsoup.**文件下安装beautifulsoup库时遇到麻烦

安装beautifulsoup库时遇到麻烦

 

win+R  ————cmd  cd (第 2 步放置安装包的位置)C:\Python36\beautifulsoup4-4.6.0

安装:python steup.py install

二. 安装及介绍Beautiful Soup库

安装beautiful soup库

#安装
pip install beautifulsoup4
#检查
from bs4 import Beautiful Soup
#安装 lxml
pip install lxml
捷径

相关文章: