日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python微信消息定时_python实现给微信指定好友定时发消息

發布時間:2023/12/20 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python微信消息定时_python实现给微信指定好友定时发消息 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

python有很多有趣的庫,其中wxpy是連接微信的接口,具體可以查看官方文檔:http://wxpy.readthedocs.io/zh/latest/index.html。可以實現自動操作,wxpy 支持 Python 3.4-3.6,以及 2.7 版本。

一、安裝

win10環境,直接在cmd中,輸入

pip install wxpy

有時網絡不穩定,可能出現錯誤,重新執行操作嘗試一下。

二、簡單介紹

# 導入模塊

from wxpy import *

# 初始化機器人,掃碼登陸

bot = Bot()

# 搜索名稱含有 "游否" 的男性深圳好友

my_friend = bot.friends().search('游否', sex=MALE, city="深圳")[0]

三、詳細代碼

打開cmd,執行jupyter notebook,打開ipython環境,在打開的瀏覽器頁面中,新建一個python3的ipynb文件。

from __future__ import unicode_literals

from threading import Timer

from wxpy import *

import requests

bot = None

def get_news():

#獲取一個連接中的內容

url = "http://open.iciba.com/dsapi/"

r = requests.get(url)

print(r.json())

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

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

return contents,translation

def login_wechat():

global bot

bot = Bot()

# bot = Bot(console_qr=2,cache_path="botoo.pkl")#linux環境上使用

def send_news():

if bot == None:

login_wechat()

try:

my_friend = bot.friends().search(u'xxx')[0] #xxx表示微信昵稱

my_friend.send(get_news()[0])

my_friend.send(get_news()[1][5:])

my_friend.send(u"咦?我是自動人!!")

t = Timer(360, send_news) #360是秒數

t.start()

except:

print(u"失敗!!")

if __name__ == "__main__":

send_news()

print(get_news()[0])

然后按ctrl+enter鍵執行。

總結

以上是生活随笔為你收集整理的python微信消息定时_python实现给微信指定好友定时发消息的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。