我收到来自 api 的请求。我怎样才能从中得到 file_url ?
I am getting request from api. How can I get the file_url from it?
代码:
response = requests.get('https://safebooru.org/index.php?page=dapi&s=post&q=index&limit=1')
print(response.content)
await channel.send(response.content)
要求:
enter image description here
from xml.etree import ElementTree
@commands.command()
async def sb(self, ctx):
response = requests.get('https://safebooru.org/index.php?page=dapi&s=post&q=index&limit=1')
tree = ElementTree.fromstring(response.content)
file_urls = [t.get('file_url') for t in tree]
...
代码:
response = requests.get('https://safebooru.org/index.php?page=dapi&s=post&q=index&limit=1')
print(response.content)
await channel.send(response.content)
要求: enter image description here
from xml.etree import ElementTree
@commands.command()
async def sb(self, ctx):
response = requests.get('https://safebooru.org/index.php?page=dapi&s=post&q=index&limit=1')
tree = ElementTree.fromstring(response.content)
file_urls = [t.get('file_url') for t in tree]
...