【发布时间】:2019-07-14 21:14:50
【问题描述】:
我想确定一个 beautifulsoup 请求的返回是否像这样。
Out[32]:
<?xml version="1.0" encoding="utf-8"?>
<boardgames termsofuse="https://boardgamegeek.com/xmlapi/termsofuse">
<boardgame>
<error message="Item not found"/>
</boardgame>
</boardgames>
我可以使用以下方法提取上一个输出的中心:
soup.find_all('boardgame')[0], which produces the following:
Out[24]:
<boardgame>
<error message="Item not found"/>
</boardgame>
我觉得这应该很容易,并且我尝试了以下操作,但我仍然无法确定“错误消息 =“未找到项目”是否在那里。我在这里缺少什么?
soup.findAll('boardgame')[0].getText()
Out[26]: '\n\n'
【问题讨论】:
标签: python xml beautifulsoup