O
O
Oneechane2021-09-11 13:25:07
Python
Oneechane, 2021-09-11 13:25:07

I wrote a python code for the Discord bot so that it would throw pictures, I can’t understand what the problem is either in the site or in the code itself?

@bot.command()
async def anime(ctx):
  response = requests.get("https://www.pixiv.net/en/")
  json_data = json.loads(response.text)

  embed = discord.Embed(color =0xff9900, title = 'Anime')
  embed.set_image(url = json_data["link"])
  await ctx.send(embed = embed)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2021-09-11
@Oneechane

And you are a sly one!)
We do this:

import requests

response = requests.get('https://www.pixiv.net/en/')
print(response.text)

and look at the console.
Or like this:
import requests

response = requests.get('https://www.pixiv.net/en/')

with open('1.html','w') as file:
  file.write(response.text)

and open 1.html in the browser:
613c87f1923f3624456566.png
Carefully look, is it json?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question