Пытаюсь запустить ТГ бота с трансляцией котировок один раз в час
Но сталкиваюсь с проблемой в силу своей не опытности
Что делаю не так?
Помогите пож-та
Вылетает ошибка
C:\Python\Python312\python.exe "C:\Users\Арт\Downloads\Python1\Python\Запрос котировок раз в час\test_v4.py"
Traceback (most recent call last):
File "C:\Users\Арт\Downloads\Python1\Python\Запрос котировок раз в час\test_v4.py", line 3, in <module>
from telegram import Bot, Update, run_async
ImportError: cannot import name 'run_async' from 'telegram' (C:\Python\Python312\Lib\site-packages\telegram\__init__.py)
Process finished with exit code 1
Но сталкиваюсь с проблемой в силу своей не опытности
Что делаю не так?
Помогите пож-та
Python:
import time
import requests
from telegram import Bot, Update, run_async
from bs4 import BeautifulSoup
bot = Bot(token="MY_TOKEN")
def get_quotes():
url = "https://www.google.com/search?q=курс+btc+к+рублю&oq=курс+bv&aqs=chrome.0.69i59j46i131i433j69i60l2.2072j0j7&sourceid=chrome&ie=UTF-8&sa=X&ved=2ahUKEwjVovettfX4AhUzAxAIHaZlAmIQv94EZAH6BAgQEAM"
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
result = {
"btc_rub": soup.select_one("#resultStats div.st").text.strip()
}
return (result)
@run_async
def main():
while True:
quotes = get_quotes()
bot.send_message(
chat_id="CHAT_ID",
text="Курс биткоина к рублю: {} рублей".format(quotes["btc_rub"])
)
time.sleep(3600)
if __name__ == "__main__":
main()
Вылетает ошибка
C:\Python\Python312\python.exe "C:\Users\Арт\Downloads\Python1\Python\Запрос котировок раз в час\test_v4.py"
Traceback (most recent call last):
File "C:\Users\Арт\Downloads\Python1\Python\Запрос котировок раз в час\test_v4.py", line 3, in <module>
from telegram import Bot, Update, run_async
ImportError: cannot import name 'run_async' from 'telegram' (C:\Python\Python312\Lib\site-packages\telegram\__init__.py)
Process finished with exit code 1
Последнее редактирование: