python 給微信好友發訊息

2021-08-24 18:10:26 字數 1714 閱讀 6029

傳送搞定了,接收沒搞定,有時間再搞

#pip install wxpy

from __future__ import unicode_literals

from threading import timer

from wxpy import *

import requests

#機械人

bot = bot()

defget_news

(): url = ""

r = requests.get(url)

content = r.json()['content']

note = r.json()['note']

return content,note

defsend_news

(str):

try:

#contents = [2,2,3]

#好友列表 備註顯示

#print(bot.friends())

print(bot.friends().search(u'木頭人'))

#my_friend = bot.friends().search(u'莫')[0]

#傳送#my_friend.send(contents[0])

#傳送#my_friend.send_image("c:\\users\\administrator.000\\desktop\\intiloading.png")

#my_friend.send_video('my_video.mov')

# 傳送檔案

#my_friend.send_file('my_file.zip')

# 以動態的方式傳送 沒啥用

#不能發給自己會報錯

# my = bot.friends().search(u'靈魂攻城獅')[0]

# my.send("傳送")

except :

my = bot.friends().search(u'靈魂攻城獅')[0]

my.send("傳送失敗了")

if __name__ == '__main__':

# str = input("輸入q退出")

# if str == "q":

# exit(0)

# else:

send_news(str)

#sys.exit()

微信群發訊息

準備工作需要安裝itchat api easy install itchat coding utf8 import itchat,time itchat.auto login true sincere wish u 祝 s新年快樂!friendlist itchat.get friends upda...

python之微信自動給女朋友發訊息指令碼

猶豫這都是以前寫的,有點撈,別噴,要臉,話不多說,直接上 from future import unicode literals from threading import timer from wxpy import import requests from lxml import etree i...

呼叫微信的群發訊息

一開始測試的引數形式是 然後呼叫方法如下 傳送文字訊息 defself.send bai e ke cheng open ids access token get access token 這個get access token要自己寫,是獲取access token的方法。end接下來在consol...