【发布时间】:2023-03-04 03:24:01
【问题描述】:
我是 BeautifulSoup 的新手,昨天刚刚创建了我的第一个脚本。这是一些没有得到我期望的结果的代码:
html = """<a href="http://www.example.com"><b>Text</b> and more text</a>"""
exampleSoup = BeautifulSoup(html, "html.parser")
print exampleSoup.a.string
我希望得到...
<b>Text</b> and more text
但我得到“无”。我在错误地假设什么?
我对 html 变量进行了诊断,但(正如预期的那样)这似乎不是解析问题,因为一切都与字符串上的原始内容差不多。
【问题讨论】:
标签: python python-2.7 beautifulsoup