Python bot电报

问题描述 投票:0回答:1

我正在构建一个Telegram机器人来跟踪亚马逊的价格。现在,我遇到了一个问题,因为当我在树莓派(python3 name.py)上启动它时,它不起作用。我正在尝试修复它,但我找不到错误(这不是语法错误)。这里是代码,如果有人可以帮助我,谢谢。

import request
import telepot
import time
from bs4 import BeautifulSoup

URL = 'there's an amazon URL inside these'

headers = {"User-Agent": 'my version'}


def check_price():
    page = requests.get(URL, headers=headers)


    soup = BeautifulSoup(page.content, 'html.parser')



    title = soup.find(id='productTitle').get_text()
    price = soup.find(id='priceblock_ourprice').get_text()
    converted_price = float(price[0:5]) 




def send_message_auto():
    chat_id = msg['chat']['id']
    comando = msg['text']

    if(converted_price < 942):
        bot.sendMessage(chat_id, title, converted_price)
    if comando == '/check':
        bot.sendMessage(chat_id, title, converted_price)
    if comando == '/start':
        bot.sendMessage(chat_id, title, converted_price)

bot = telepot.Bot('my key')
bot.message_loop('price')
python bots telegram
1个回答
0
投票

您是否已将Telepot / beautifulsoup4软件包安装到树莓派中?如果没有,则https://www.raspberrypi.org/documentation/linux/software/python.md

© www.soinside.com 2019 - 2024. All rights reserved.