如何从bs4导入BeautifulSoup? [英] How can I from bs4 import BeautifulSoup?

查看:533
本文介绍了如何从bs4导入BeautifulSoup?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码:

from bs4 import BeautifulSoup  

不起作用,并显示此错误:

Doesn't work, and gives this error :

raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__,attr)    
                    ^
SyntaxError: invalid syntax    

我该怎么办?

推荐答案

您应该使用pip进行安装,因此您可以轻松完成

You should be using pip to install, so you can simply do

pip install beautifulsoup4

这将安装最新的BS4,截至2013年8月15日为4.3.1.它支持Python 3.

That will install the latest BS4, which is 4.3.1 as of 2013-08-15. It supports Python 3.

这篇关于如何从bs4导入BeautifulSoup?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆