尝试使用soupparser解析HTML时,我在标题中收到错误 - BeautifulSoup HTML解析器的外部接口。这是我的代码:
from lxml.html.soupparser import fromstring
fromstring("<html><body></body></html>");
另外,既然我正在使用Anaconda的Python发行版,我就像这样加载了BeautifulSoup:
import sys, bs4
sys.modules['BeautifulSoup'] = bs4
我得到的错误是:TypeError: __init__() got an unexpected keyword argument 'convertEntities'
当soupparser调用bs4时:
if 'convertEntities' not in bsargs:
bsargs['convertEntities'] = 'html'
tree = beautifulsoup(source, **bsargs)
另外,我第一次在IPython笔记本中运行它时,收到以下警告:
.../python2.7/site-packages/bs4/__init__.py:88: UserWarning: BS4 does not respect the convertEntities argument to the BeautifulSoup constructor. Entities are always converted to Unicode characters.