使用BeautifulSoup和Requests从xml文件中打印数据

太空滑翔机

我正在尝试使用BeautifulSoup4和Requests刮取XML页面的数据,但是我似乎无法打印结果。我没有收到错误,但是没有数据打印。

import time
import requests
from bs4 import BeautifulSoup

url = "website.com?xml=1"
result = requests.get(url)

content = result.content
soup = BeautifulSoup(content, "html.parser")

steamID = soup.find_all("x")
print (y)
奥马尔·穆罕默德(OMar Mohamed)

您应该使用xml解析器:

soup = BeautifulSoup(content, "xml")

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章