import requests
headers = {
'x-uid': '61fbadfb8616a'
}
data = {
"operationName": "catalogProductsBoard",
"variables":
{
"sort": "DEFAULT",
"attributes": [
{
"slug": "categories",
"value": [""],
"from": None,
"to": None
}],
"datePublished": None,
"location":
{
"latitude": None,
"longitude": None,
"city": "576d0612d53f3d80945f8b5d",
"distanceMax": None
},
"search": "",
"cursor": "{\"page\":1,\"totalProductsCount\":60,\"totalPremiumProductsCount\":4,\"dateUpdatedTo\":1651722922}"
},
"extensions":
{
"persistedQuery":
{
"version": 1,
"sha256Hash": "bf7a22ef077a537ba99d2fb892ccc0da895c8454ed70358c0c7a18f67c84517f"
}
}
}
response = requests.post("https://api-gw.youla.io/federation/graphql", json=data, headers=headers).json()
print(response)
STATUS_OK = 200
url = 'https://www.avito.ru/moskva/avtomobili?p={page}&radius=100'
page = 1
status = 200
while status == STATUS_OK:
response = requests.get(url.format(page=page))
if response.status_code == STATUS_OK:
page += 1
print("Working...")
else:
status = response.status_code
print("Всего страниц: ", page)
@bot.callback_query_handler(func=lambda call: True)
@bot.callback_query_handler(func=lambda call: True)
def choice_course(call):
if call.data == 'usd':
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=f"На {date_and_time}\n\nКурс {usd_name}: {usd}")
else:
today = datetime.datetime.now()
date_and_time = (today.strftime('%Y-%m-%d %H:%M:%S'))
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Выберите валюту", reply_markup=kd.choice_cource)
usd = data['Valute']['USD']['Value']
usd_name = data['Valute']['USD']['Name']
@bot.callback_query_handler(func=lambda call: call.data=='usd')
def course(call):
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=f"На {date_and_time}\n\nКурс {usd_name}: {usd}")