Python IDchat 微信接口发消息
1号程序
import itchat
import datetime
import time
import requests
itchat.auto_login(hotReload = True)
users1 = itchat.search_friends(name=u'某人') #查找好友名字
users2 = itchat.search_chatrooms(name=u'某群') #查找好友名字
userName1 = users1[0]['UserName'] #获取名字
userName2 = users2[0]['UserName'] #获取名字
def get_news():
url = "http://www.weather.com.cn/data/cityinfo/101200101.html" #天气信息来源 101200401孝感
r = requests.get(url) #get函数
r.encoding = 'utf-8' #转码utf-8
#total = r.json()
#print(total)
city = r.json()['weatherinfo']['city']
# humidity = r.json()['data']['shidu']
# pm25 = r.json()['data']['pm25']
# airQuality = r.json()['data']['quality']
# temperature = r.json()['data']['wen