FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml.

运行下面代码:
        page = requests.get(url)  #url是一个网址
        soup = BeautifulSoup(page.text, 'lxml')

报错:

  File "<ipython-input-324-9cb4fa68f64f>", line 1, in <module>
    BeautifulSoup(page.text, 'lxml')

  File "...\lib\site-packages\bs4\__init__.py", line 245, in __init__ % ",".join(features))

FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

解决方法:

       soup = BeautifulSoup(page.text, 'lxml') 改为 soup = BeautifulSoup(page.text, "html.parser")

本来先在anaconda安装了lxml,能在spyder import成功,但是再次运行代码仍然报一养的错,应该是我没有安装成功,抱着试试的心态换成"html.parser"能运行。但是lxml为啥还会报错仍然有待探究。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值