python编写自动发送微信信息(python实现向微信用户发送每日一句 python实现微信聊天机器人)
类别:脚本大全 浏览量:1794
时间:2021-10-28 10:47:45 python编写自动发送微信信息
python实现向微信用户发送每日一句 python实现微信聊天机器人分享几个python针对微信的小工具,供大家参考,具体内容如下
用python实现向微信用户发送每日一句
|
# -*- coding:utf-8 -*- from __future__ import unicode_literals from threading import timer from wxpy import * import requests #bot = bot() #bot = bot(console_qr=2,cache_path="botoo.pkl")#这里的二维码是用像素的形式打印出来!,如果你在win环境上运行,替换为 bot=bot() bot = bot(cache_path = true) def get_news1(): #获取金山词霸每日一句,英文和翻译 url = "http://open.iciba.com/dsapi/" r = requests.get(url) contents = r.json()[ 'content' ] translation = r.json()[ 'translation' ] return contents,translation def send_news(): try : my_friend = bot.friends().search(u '浩' )[ 0 ] #你朋友的微信名称,不是备注,也不是微信帐号。 my_friend.send(get_news1()[ 0 ]) my_friend.send(get_news1()[ 1 ][ 5 :]) my_friend.send(u "以上是金山词霸每日一句,http://www.qq.com\" data-miniprogram-appid=\"wxae430cc3e778834b\" data-miniprogram-path=\"pages/gologin/gologin\"" ) t = timer( 10 , send_news) #每86400秒(1天),发送1次,不用linux的定时任务是因为每次登陆都需要扫描二维码登陆,很麻烦的一件事,就让他一直挂着吧 t.start() except : my_friend = bot.friends().search( '回憶總是如此伤' )[ 0 ] #你的微信名称,不是微信帐号。 my_friend.send(u "今天消息发送失败了" ) if __name__ = = "__main__" : send_news() |
用python调用图灵机器人接口实现微信聊天机器人
|
import kivy kivy.require( '1.9.1' ) from kivy.app import app from kivy.uix.button import button import itchat import requests class test(app): def get_response(msg): apiurl = 'http://www.tuling123.com/openapi/api' data = { 'key' : '0646d90819004f2fa565852c0fe3c3af' , # tuling key 'info' : msg, # 这是我们发出去的消息 'userid' : '123' , # 这里你想改什么都可以 } # 我们通过如下命令发送一个post请求 r = requests.post(apiurl, data = data).json() return r.get( 'text' ) @itchat .msg_register(itchat.content.text) def print_content(msg): return get_response(msg[ 'text' ]) @itchat .msg_register([itchat.content.text], isgroupchat = true) def print_content(msg): return get_response(msg[ 'text' ]) itchat.auto_login(true) itchat.run() if __name__ = = '__main__' : test().run() |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持开心学习网。
原文链接:https://blog.csdn.net/qq_34956264/article/details/88662503
您可能感兴趣
- python 从入门到实践笔记(python基础梳理一推荐)
- python与mysql的联系(MySQL和Python交互的示例)
- python环境怎么安装pip(python2.7 安装pip的方法步骤管用)
- python如何将运行结果存入txt中(详解python读取和输出到txt)
- python的遍历循环(对python For 循环的三种遍历方式解析)
- python最火开源项目(5月份Github上Python开源项目排行)
- python之pil模块使用(Python3安装Pillow与PIL的方法)
- python的opencv图片识别(OpenCV-Python 摄像头实时检测人脸代码实例)
- python 组合数据类型(详解Python3 对象组合zip和回退方式*zip)
- python爬虫怎么爬取vip资源(Python网络爬虫之爬取微博热搜)
- python协程结果(深入浅析python 协程与go协程的区别)
- python解析视频源码(基于python实现高速视频传输程序)
- python字典的值排序(python 对字典按照value进行排序的方法)
- python 3.10 循环语法(Python3.4学习笔记之常用操作符,条件分支和循环用法示例)
- python元组和列表的定义(Python基本数据结构与用法详解列表、元组、集合、字典)
- python怎么导入xlsx(用Python将结果保存为xlsx的方法)
- 金球奖只青睐那些会戴珠宝的女人(金球奖只青睐那些会戴珠宝的女人)
- 浙江省一个县,人口超40万,建县历史超1100年(浙江省一个县人口超40万)
- 五代十国南唐历代国君(五代十国南唐历代国君)
- 飞机引进工程师杨隆 匠人匠心,只争朝夕(飞机引进工程师杨隆)
- 三人行,她们是育人路上的 铁三角 团队(她们是育人路上的)
- 阴阳师 孟婆山兔CP不倒 新皮肤草稿 孟婆兔 让痒痒鼠点赞(阴阳师孟婆山兔CP不倒)
热门推荐
- php如何调用类(php创建类并调用的实例方法)
- cookie政策及设置(详解操作cookie的原生方法cookieStore)
- docker从一个容器中退出来(Docker容器迁移到其他服务器的5种方法详解)
- centos7配vlan(如何在 CentOS/RHEL 系统中使用带 VLAN 标记的以太网卡)
- 云服务器可以搭建几个网站(使用云服务器搭建网站的注意事项)
- js柯里函数的应用场景(深入详解JS函数的柯里化)
- nginx启动报错连接失败(宝塔面板Nginx环境中出现404 Not Found的解决方法)
- dede模板手机端显示设置(DEDE模板中如何运行php脚本和变量在需要操作数据库字段时)
- springcloud部署docker(Spring Cloud中使用jib进行docker部署的步骤详解)
- webapi 参数的传递
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9