出现此错误通常是由于BeautifulSoup解析不稳定导致的。可以尝试以下解决办法:
html_doc = """
The Dormouse's story
Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.
...
"""from bs4 import BeautifulSoup soup = BeautifulSoup(html_doc, 'html.parser') print(soup.find_all('p')) # 正常情况下应该可以查询到所有
标签
soup = BeautifulSoup(html_doc, 'lxml') # 使用lxml解析器 print(soup.find_all('p'))
print(soup.select_one('p.title b'))