V
V
Vipka1n2020-12-11 13:11:30
Python
Vipka1n, 2020-12-11 13:11:30

How to parse GetUpdate output (api.telegram)?

You need to get file_id everything that is in the issue
Who will advise what, what will tell.

import json
import requests
url = 'https://api.telegram.org/bot10000:ЫЫЫЫЫЫЫЫ/getUpdates'
response = requests.get(url)
resp = response.json()
jstr = resp['result']
jstrl = jstr['message']
content = jstrl['audio']
print(content)
print(content['file_id'])


JSON Issuance
ok	true
result	
0	
update_id	00000
message	
message_id	01
from	
id	0000
is_bot	false
first_name	"no"
last_name	"Name"
username	"noName"
language_code	"ru"
chat	
id	00000
first_name	"no"
last_name	"Name"
username	"noName"
type	"private"
date	1607678793
document	
file_name	"document.pdf"
mime_type	"application/pdf"
thumb	
file_id	"AAMCAgADGQEAA1Vf0ztJUTRZv16zCvIta1PlNYPcHwACSQkAAlRRmUoOy7x4xdX3hCV2ZwuAAMBAAdtAAOrLgACHgQ"
file_unique_id	"AQADEJXZnC4AA6suAAI"
file_size	16470
width	226
height	320
file_id	"BQACAgIAAxkBAANVX9M7SVE09eswryLWtT5TWD3B8AAkkJAAJUUZlKDsu4seMXV94eBA"
file_unique_id	"AgADSQkAAlRRmUo"
file_size	130345
1	
update_id	00000
message	
message_id	86
from	
id	000000
is_bot	false
first_name	"noName"
last_name	"noName"
username	"Noname"
language_code	"ru"
chat	
id	00000
first_name	"N"
last_name	"Name"
username	"noname"
type	"private"
date	1607678809
audio	
duration	184
file_name	"audio.mp3"
mime_type	"audio/mpeg3"
title	"Бэнгер"
performer	"audio"
file_id	"CQACAgIAAxkBAANWX9M7Wbn4wC2pv8DnR_I7zkMgWr4AAkoJAAJUUZlK3cgpAd--a1MeBA"
file_unique_id	"AgADSgkAAlRRmUo"
file_size	3039879

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question