【问题标题】:How to get rid of the BeautifulSoup html parser error when I'm not using BeautifulSoup当我不使用 BeautifulSoup 时如何摆脱 BeautifulSoup html 解析器错误
【发布时间】:2018-01-01 00:40:15
【问题描述】:

我打算用 GUI 制作一个字典程序,但我遇到了第一个障碍。我刚刚安装了一个模块 (PyDictionary),但是当我运行以下代码时出现错误。

from PyDictionary import PyDictionary
dictionary = PyDictionary()
print(dictionary.meaning("fish"))

返回

The code that caused this warning is on line 3 of the file Dictionary.py. To 
get rid of this warning, change code that looks like this:

 BeautifulSoup(YOUR_MARKUP})

to this:

 BeautifulSoup(YOUR_MARKUP, "lxml")

  markup_type=markup_type))
{'Noun': ['any of various mostly cold-blooded aquatic vertebrates usually having scales and breathing through gills', 'the flesh of fish used as food', '(astrology', 'the twelfth sign of the zodiac; the sun is in this sign from about February 19 to March 20'], 'Verb': ['seek indirectly', 'catch or try to catch fish or shellfish']}

【问题讨论】:

  • PyDictionary 使用 BeautifulSoup,所以通过使用 PyDictionary,您实际上是在使用 BeautifulSoup。
  • 看起来 PyDictionary 已经过时了,因为它利用了网络请求,并且使用了旧的 HTML 解析器。

标签: python python-3.x beautifulsoup


【解决方案1】:

看起来这是 PyDictionary 的问题,如 here 所述。它抛出 BeautifulSoup 错误的原因是 PyDictionary 是使用 BeautifulSoup 实现的。

不过,问题似乎已得到解决。您是否使用 pip 安装了 PyDictionary?如果是这样,请尝试直接从 GitHub 存储库 here 安装。

编辑:我使用 repo 进行了安装测试,问题已解决。我建议你也这样做。如果您不确定如何执行此操作,请随时询问。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-08
    • 2016-02-04
    • 2013-03-10
    • 1970-01-01
    • 2016-09-02
    • 1970-01-01
    • 1970-01-01
    • 2012-12-13
    相关资源
    最近更新 更多