缺少3个必需的位置参数:“自我”,“至”和“消息”

时间:2019-11-28 06:33:48

标签: python selenium

我想做什么

从门户网站获取信息,然后将其推送到手机上的LINE应用程序中。

错误

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

源代码

使用Selenium获取信息的过程似乎运行良好,因此将其省略。

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和编程的新手。

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

尝试一下:

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()