【发布时间】:2015-02-15 17:07:41
【问题描述】:
我找到了一个较旧的 Python 代码,其中包含这一行:
return BeautifulSoup(m.group(1),
convertEntities=BeautifulSoup.HTML_ENTITIES).contents[0].string
当我尝试运行代码时出现此错误:
AttributeError: type object 'BeautifulSoup' has no attribute 'HTML_ENTITIES
谁能解释一下这行的意思:
BeautifulSoup(m.group(1),convertEntities=BeautifulSoup.HTML_ENTITIES).contents[0].string
以及如何在新版本中使用 formater 来做到这一点?
我知道有一个类似的问题在这里回答: BeautifulSoup' has no attribute 'HTML_ENTITIES 但由于我不熟悉 BeautifulSoup,我无法将行转换为新格式。
非常感谢您对此的任何帮助。
【问题讨论】:
标签: python html python-2.7 beautifulsoup