@bot.message_handler(commands=['search'])
def repeat_all_messages(message):
bot.send_message(message.chat.id,'Введите запрос:')
x = message.text
print(x)
search = message.text
shmak = search.replace(' ', "+")
URL = 'https://store.steampowered.com/search/?term='+ shmak
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19041'
}
responce = requests.get(URL,headers=headers)
soup = BeautifulSoup(responce.text, 'lxml')
games = soup.find_all('a', class_='search_result_row ds_collapse_flag')
for n,i in enumerate(games,start=1):
title = i.find('div', class_='col search_name ellipsis').find('span', class_='title')
try:
price = i.find('div', class_='col search_price responsive_secondrow').text
except:
price = i.find('div', class_='col search_price discounted responsive_secondrow').find('strike').text
link = i.get('href')
x = f'{n}:{title.text}\n\n{price}\n{link}\n'
bot.send_message(message.chat.id, x)
if n == 10:
break
bot.infinity_polling()