简体   繁体   English

BeautifulSoup 在 html.parser 上失败

[英]BeautifulSoup failed on html.parser

I am new to BeautifulSoup, but I am trying to use the simplest html.parser, however it fails, I have checked the version I am running is BeautifulSoup4 and I am on python 3.6.我是 BeautifulSoup 的新手,但我正在尝试使用最简单的 html.parser,但它失败了,我检查了我正在运行的版本是 BeautifulSoup4,我在 python 3.6 上。 (Besides, I tried html5lib and lxml both installed but did not work for me) Is there anything I miss out here? (此外,我尝试安装了 html5lib 和 lxml 但对我不起作用)这里有什么我错过的吗?

import urllib.request
import html
from BeautifulSoup.bs4 import BeautifulSoup

webpage = "https://www.tradingview.com/markets/currencies/rates-major/"

websource = urllib.request.urlopen(webpage)

soup = BeautifulSoup(websource.read(),'html.parser')

FeatureNotFound Traceback (most recent call last) in () 7 websource = urllib.request.urlopen(webpage) 8 ----> 9 soup = BeautifulSoup(websource.read(),'html.parser') 10 11 print(soup) () 中的 FeatureNotFound Traceback(最近一次调用) 7 websource = urllib.request.urlopen(webpage) 8 ----> 9 soup = BeautifulSoup(websource.read(),'html.parser') 10 11 print(soup )

FeatureNotFound: Couldn't find a tree builder with the features you requested: html.parser. FeatureNotFound:找不到具有您请求的功能的树生成器:html.parser。 Do you need to install a parser library?您需要安装解析器库吗?

If you have installed BeautifulSoup properly then your import statement should read:如果你已经正确安装了 BeautifulSoup 那么你的导入语句应该是:

from bs4 import BeautifulSoup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM