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 ...
随机推荐
- LightGBM总结
一.LightGBM介绍 LightGBM是一个梯度Boosting框架,使用基于决策树的学习算法.它可以说是分布式的,高效的,有以下优势: 1)更快的训练效率 2)低内存使用 3)更高的准确率 4) ...
- 利用AMPScript获取Uber用户数据的访问权限
现代项目开发和资产管理方法正在不停地快速变化.在这场创新和扩张的竞赛中,新资产被迅速部署并暴露于公共互联网,已有资产也在不断发展. 要跟上这个不断变化的攻击面是很难的,更不用说保护这些应用程序和系统了 ...
- ios APNS注册失败 本地push
- (void)addLocalNotice:(NSString *)titlepush { if (@available(iOS 10.0, *)) { UNUserNotificationCent ...
- git删除和提交
//删除git分支git branch -D BranchNamegit branch -r -D origin/BranchNamegit push origin -d BranchName//提交 ...
- ubuntu16.04 backup and restore
http://blog.csdn.net/qq_35523593/article/details/78545530
- windows下redis集群安装和部署
1.下载windows版本的Redis 官网只提供linux版本的下载 官网下载地址:http://redis.io/download github下载地址:https://github.com/MS ...
- GO : 斐波纳契数列
package main import "fmt" // fibonacci is a function that returns // a function that retur ...
- laravel5.7 migrate 时报错 Specified key was too long error 解决方案
今天在数据迁移时突然报了 Specified key was too long error 的错,解决掉之后就把这个问题记录下来. 报错原因 Laravel 5.4 + 默认使用 utf8mb4 字 ...
- C#返回字符串的字节长度,一个中文算两个字符的代码
如下代码段是关于C#返回字符串的字节长度,一个中文算两个字符的代码. public static int GetLength(string str) { if (str.Length == 0) re ...
- Porsche Piwis Tester II V15.6 with CF30 Laptop or Lenovo E49AL Laptop
Some of my customers let me recommended which auto diagnostic tool is good for Porsche , I recommend ...