bs4 FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
安装beautifulsoup后,运行测试报错
from urllib import request
from bs4 import BeautifulSoup url = "http://www.baidu.com"
rsp = request.urlopen(url)
content = rsp.read() soup = BeautifulSoup(content, "lxml") print(soup.title.string)
----------------------------------------------------------------------
FeatureNotFound Traceback (most recent call last)
~/data/spider/bs.py in <module>
16 content = rsp.read()
17
---> 18 soup = BeautifulSoup(content, "lxml")
19
20 print(soup.title.string) ~/data/spider/venv/lib/python3.7/site-packages/bs4/__init__.py in __init__(self, markup, features, builder, parse_only, from_encoding, exclude_encodings, **kwargs)
196 "Couldn't find a tree builder with the features you "
197 "requested: %s. Do you need to install a parser library?"
--> 198 % ",".join(features))
199 builder = builder_class()
200 if not (original_features == builder.NAME or FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
经过测试发现是lxml的问题,使用 pip install lxml 安装,安装完后,在运行还是一样出错, 经百度、知乎的说法是新的库不支持,新版本语法支持改变了
使用 pip install lxml时,自动安装的是最新 4.2.5版本
解决方法一:
卸载新的换老的就可以了
pip uninstall lxml
pip install lxml==3.7.0
方法二:
在报错代码中把函数参数中所有的"lxml"改成"html.parser"
soup = BeautifulSoup(content, "lxml")
改成 soup = BeautifulSoup(content, "html.parser
")
bs4 FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?的更多相关文章
- 执行python 爬虫脚本时提示bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
from bs4 import BeautifulSoupfrom urllib.request import urlopenimport re html = urlopen('http://**** ...
- Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
python3.6.3 我在处理爬虫时候使用BeautifulSoup中遇到报错 “ bs4.FeatureNotFound: Couldn't find a tree builder with t ...
- python bs4解析网页时 bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to inst(转)
Python小白,学习时候用到bs4解析网站,报错 bs4.FeatureNotFound: Couldn't find a tree builder with the features you re ...
- python报错bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.
qpython运行 原代码: soup = BeautifulSoup(r.text,'lxml') 报错:bs4.FeatureNotFound: Couldn't find a tree b ...
- bs4.FeatureNotFound: Couldn’t find a tree builder with the features you requested: lxml.
python3 bs4解析网页时报错: bs4.FeatureNotFound: Couldn’t find a tree builder with the features you requeste ...
- [error:没有解析库]Couldn't find a tree builder with the features you requested: xml. Do you need to install a parser library?
将代码拷贝到服务器上运行,发生错误提示需要新安装parser library. 查看代码中发现有以下内容: soup = BeautifulSoup(open(fp), 'xml') 安装解析库即可: ...
- 【Python学习】爬虫报错处理bs4.FeatureNotFound
[BUG回顾] 在学习Python爬虫时,运Pycharm中的文件出现了这样的报错: bs4.FeatureNotFound: Couldn’t find a tree builder with th ...
- Python 中常见错误总结
IndentationError: unexpected indent Python 中强制缩进,, IndentationError: unexpected indent 缩进错误 这类错误非常常见 ...
- python运行selenium时出现的一个错误总结
1.SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame 场景:运用pan ...
随机推荐
- java面试题 wait和sleep区别
sleep() 方法是线程类(Thread)的静态方法,让调用线程进入睡眠状态,让出执行机会给其他线程,等到休眠时间结束后,线程进入就绪状态和其他线程一起竞争cpu的执行时间 wait()是Objec ...
- Postman接口自动化测试实例二
在<Postman接口自动化测试实例>一文中,我是在获取随机因子的接口的Tests中对用户的密码进行加密处理的.其实正常做法应该是在请求验证接口前,即在Pre-request Script ...
- SQL Server get SP parameters and get output fields type information
Summary 本文主要介绍一下,SQL里面的两个很实用的两个操作: 获取存储过程的参数信息 SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPE ...
- TerminateProcess实现关闭任意程序
#include <Windows.h> #include <tchar.h> int WINAPI _tWinMain(HINSTANCE hInstance, HINSTA ...
- JavaScript命名规范基础及系统注意事项
前端代码中的自定义变量命名 命名方法: 1.驼峰 2.下划线连接 对于文件名,我们一般采用小写字母+下划线的形式 为什么?因为在window下a ...
- 线段树 HDU-1754 I Hate It
附上原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某 ...
- 记录心得-FastJson分层解析demo示例
记录一下,平时用到,可速查!关键: // startArray(); 开始解析数组 // endArray(); 结束解析数组 // startObject(); 开始解析键值对 // endObje ...
- Vue 服务端渲染(SSR)
什么是服务端渲染? 简单理解是将组件或页面通过服务器生成html字符串,再发送到浏览器,最后将静态标记"混合"为客户端上完全交互的应用程序. 服务端渲染的优点 更好的SEO,搜索引 ...
- BeyondCompare使用一段时间后会因“许可证密钥已被撤销:3281-0350“而无法使用
解决方式: 1.用任意文本编辑软件打开“C:\Users\[Your User Name]\AppData\Roaming\Scooter Software\Beyond Compare 3\BCSt ...
- 易爆物D305
分析:典型的并查集,每一个物品合一看成一个独立的顶点,则一个简单化合物就是一条边,如果两个顶点x,y联通则说明有危险,所以可以用一个并查集来维护图的联通分量集合,并查集的详解有一篇写的很易懂的博客并查 ...