黑松山资源网 Design By www.paidiu.com
python有很多有趣的库,其中wxpy是连接微信的接口,具体可以查看官方文档。可以实现自动操作,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键执行。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年10月07日
2024年10月07日
- 张宇.2001-替身【EMI百代】【WAV+CUE】
- 班得瑞原装进口《第六张新世纪专辑:日光海岸》1CD[APE/CUE分轨][339.5MB]
- 班得瑞原装进口《第七张新世纪专辑:梦花园》1CD[APE/CUE分轨][331.4MB]
- 班得瑞原装进口《第八张新世纪专辑:琉璃湖畔》1CD[APE/CUE分轨][286.4MB]
- 魏如萱.2011-在哪里(EP)【添翼创越】【WAV+CUE】
- 群星.1981-新金曲奖·青年创作园地12合辑(喜玛拉雅复刻版)【歌林】【WAV+CUE】
- 麦洁文.1989-新曲与精丫新艺宝】【WAV+CUE】
- SNH48《薄荷糖 (Mint Candy)》[320K/MP3][33.72MB]
- SNH48《薄荷糖 (Mint Candy)》[FLAC/分轨][78.59MB]
- 刘美麟《同生》[320K/MP3][70.99MB]
- 群星.1994-宝丽金最流行3CD【宝丽金】【WAV+CUE】
- 群星.2024-聆听“某某”影视原声带【华纳】【FLAC分轨】
- 陈慧娴.1989-永远是你的朋友(2024环球MQA-UHQCD限量版)【环球】【WAV+CUE】
- 何洛洛.2024-别叫醒我(EP)【光羽】【FLAC分轨】
- 林忆莲.1996-爱莲说2CD【华纳】【WAV+CUE】