从门户网站获取信息,然后将其推送到手机上的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和编程的新手。
答案 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()