用Python给微信好友自动发送祝福语
学习了Python知识,可以做许多好玩的东西,可以用Python统计分析好友状态、好友性别、年龄、地区,以及好友签名等内容,今天咱们就用Python自动给微信好友发祝福语。
程序实现
(1)导包
from __future__ import unicode_literals
from threading import Timer
from wxpy import *
import requests
bot = Bot()
(2)获取文字来源
def get_news():
"""获取金山词霸每日一句,英文和翻译"""
url = "http://open.iciba.com/dsapi/"
r = requests.get(url)
content = r.json()['content']
note = r.json()['note']
return content, note
(3)定义好友的微信名称
def send_news():
try:
contents = get_news()
# 输入你朋友的微信名称,不是备注,也不是微信帐号。
# 例如这里我输入的是“小明”。
my_friend = bot.friends().search(u'小明')[0