【问题标题】:BeautifulSoup failed on html.parserBeautifulSoup 在 html.parser 上失败
【发布时间】:2018-08-26 21:48:08
【问题描述】:

我是 BeautifulSoup 的新手,但我正在尝试使用最简单的 html.parser,但是它失败了,我检查了我正在运行的版本是 BeautifulSoup4,我在 python 3.6 上。 (此外,我尝试安装了 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 (最近一次调用最后一次) in () 7 websource = urllib.request.urlopen(webpage) 8 ----> 9 soup = BeautifulSoup(websource.read(),'html.parser') 10 11打印(汤)

FeatureNotFound:找不到具有您请求的功能的树构建器:html.parser。需要安装解析器库吗?

【问题讨论】:

  • 如果你已经正确安装了 BeautifulSoup,那么你的导入语句应该是from bs4 import BeautifulSoup
  • 非常感谢,它解决了我的问题!非常感谢
  • 欢迎您! --------

标签: python beautifulsoup


【解决方案1】:

如果您已正确安装 BeautifulSoup,那么您的导入语句应为:

from bs4 import BeautifulSoup

【讨论】:

    猜你喜欢
    • 2016-07-11
    • 2019-02-17
    • 2021-06-16
    • 2013-04-28
    • 2012-07-12
    • 2021-01-24
    • 2018-01-11
    • 1970-01-01
    • 2014-04-13
    相关资源
    最近更新 更多