Ошибка импорта: невозможно импортировать имя «Обновление» из «Telegram»
Код: Выделить всё
import requests
from bs4 import BeautifulSoup
from telegram import Update
TOKEN = 'YOUR_TELEGRAM_BOT_TOKEN'
def start(update: Update, context: CallbackContext):
context.bot.send_message(chat_id=update.effective_chat.id, text="Welcome to the product search bot! Please enter a product name to search for.")
def search_product(update: Update, context: CallbackContext):
product_name = update.message.text
url = f'https://example.com/search?q={product_name}'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
products = soup.find_all('div', class_='product')
for product in products:
name = product.find('h3', class_='product-name').text.strip()
price = product.find('div', class_='product-price').text.strip()
context.bot.send_message(chat_id=update.effective_chat.id, text=f'{name}\n{price}')
def main():
updater = Updater(TOKEN)
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
dp.add_handler(MessageHandler(Filters.text & ~Filters.command, search_product))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
pip install python-telegram-bot --upgrade --force-reinstall
из обновления импорта телеграммы
но это не помогло
Подробнее здесь: https://stackoverflow.com/questions/759 ... m-telegram