Answer the question
In order to leave comments, you need to log in
What is the best way to combine?
What is the best way to combine this part of the code
import requests
import json
answer = requests.get('api')
data = (json.loads(answer.text))
print(json.loads(answer.text)[0]['title'])
print(json.loads(answer.text)[0]['domain'])
print(json.loads(answer.text)[0]['conclusion'])
print(json.loads(answer.text)[0]['product']['price']['price'][17])
@bot.message_handler(content_types=["text"])
def lalala(message):
text = message.text
if 'amazon' in text:
try:
product_id = text.split('/', 6)[5]
bot.send_message(message.chat.id, f'Amazon - {product_id}')
except Exception:
bot.send_message(message.chat.id, 'Не верная ссылка')
text = message.text
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question