【问题标题】:FeatureNotFound: Couldn't find a tree builder with the features you requested – Webscraping with PandasFeatureNotFound:找不到具有您要求的功能的树构建器 – 使用 Pandas 进行网络抓取
【发布时间】:2018-02-21 15:12:21
【问题描述】:

我正在学习 Python 来组织一个网页抓取技能项目。我在下载足球统计数据表时遇到问题。我收到以下错误:

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

这是我的完整代码。非常感谢任何帮助。

import pandas as pd
import requests
from bs4 import BeautifulSoup

res = requests.get("http://www.fftoday.com/stats/playerstats.php?Season=2002&GameWeek=1&PosID=10&LeagueID=26955")
soup = BeautifulSoup(res.content,'lxml')
table = soup.find_all('table')[1]


  Traceback (most recent call last):

  File "<ipython-input-20-e6d65d59d7e8>", line 6, in <module>
    soup = BeautifulSoup(res.content,'lxml')

  File "C:\Users\Unciv\Anaconda3\envs\ML27\lib\site-packages\bs4\__init__.py", line 165, 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?

【问题讨论】:

  • 你可能想安装lxml

标签: python pandas web-scraping beautifulsoup


【解决方案1】:

如果lxml不存在,可以使用安装

pip install lxml

您也可以使用不同的解析器来达到同样的效果。 html.parserhtml5lib 默认都可用。

soup = BeautifulSoup(res.content,'html.parser')

这应该可以解决抓取网页的问题。一旦你抓取了它,我认为你需要加载table[3],以获取玩家统计数据表。

【讨论】:

    猜你喜欢
    • 2018-06-14
    • 2017-02-20
    • 2017-02-28
    • 2017-11-17
    • 2020-07-02
    • 2020-07-09
    • 1970-01-01
    • 2019-11-07
    相关资源
    最近更新 更多