缺少3个必需的位置参数:“self”、“to”和“messages”

2024-09-29 21:42:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我想做什么

从门户网站获取信息并将其推送到我手机上的在线应用程序。你知道吗

错误

TypeError: push_message() missing 3 required positional arguments: 'self', 'to', and 'messages'

源代码

用硒获取信息的过程似乎运行良好,因此省略了它。你知道吗

from selenium import webdriver
import time
import pyautogui as auto
from bs4 import BeautifulSoup
from linebot.models import TextSendMessage
from linebot.exceptions import LineBotApiError

ID = ''
PASS = ''

from linebot import LineBotApi
from linebot.models import TextSendMessage

LINE_CHANNEL_ACCESS_TOKEN=''



def main():
    main = 'test'
    user_id = ""
    send=LineBotApi.push_message()
    send(to=user_id, messages=TextSendMessage(text=main))

main()

我所尝试的

我已经添加了def main():,但仍然不能解决问题。你知道吗

附加信息

我是Python和编程的新手。你知道吗


Tags: tofromimportsendidmessagemainmodels
2条回答

试试这个:

from selenium import webdriver
import time
import pyautogui as auto
from bs4 import BeautifulSoup
from linebot.models import TextSendMessage
from linebot.exceptions import LineBotApiError

ID = ''
PASS = ''

from linebot import LineBotApi
from linebot.models import TextSendMessage

LINE_CHANNEL_ACCESS_TOKEN=''



def main():
    main_text = 'test'
    user_id = ""
    send=LineBotApi().push_message(to=user_id,    message=TextSendMessage(text=main_text))

if __name__ == '__main__':
    main()
try:
    line_bot_api.push_message('<to>', TextSendMessage(text='Hello World!'))
except LineBotApiError as e:
    # error handle

更多信息:

https://developers.line.biz/en/reference/messaging-api/#send-push-message

相关问题 更多 >

    热门问题