2017-09-13 36 views
2

我正在学习Python,为网络抓取技巧组织一个项目。我无法下载足球统计数据表。我收到以下错误:FeatureNotFound:无法找到具有您请求的功能的树状构建器 - 使用熊猫进行网页扫描

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? 
+0

您可能需要安装[lxml](http://lxml.de/installation.html) – ShreyasG

回答

2

如果lxml不存在,你可以使用

pip install lxml 

你也可以使用不同的解析器达到同样的效果进行安装。 html.parserhtml5lib默认都可用。

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

这应该解决抓取网页的问题。一旦你刮了它,我认为你需要加载table[3],球员统计表。