吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 343|回复: 3
收起左侧

[求助] 数据推送!

[复制链接]
milu1123 发表于 2022-8-26 15:20
本帖最后由 milu1123 于 2022-8-26 16:12 编辑

下面代码可以提取到天气预报,不会优化,
想一对一的微信好友推送(或多人,群),定时发送,或随机1小时内发送
不是公众号的形式

有谁能帮忙在优化一下嘛??

import requests

diqu = input("请输入地区:")
head = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                      'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'
        }
key = '这里输入和风天气的key'
url = f'https://geoapi.qweather.com/v2/city/lookup?location={diqu}&key={key}'
resp = requests.get(url, headers=head).json()
diqu_id = resp["location"][0]["id"]
url1 = f'https://devapi.qweather.com/v7/weather/now?location={diqu_id}&key={key}'
resp1 = requests.get(url1, headers=head).json()
url2 = f'https://devapi.qweather.com/v7/indices/1d?type=1,2&location={diqu_id}&key={key}'
resp2 = requests.get(url2, headers=head).json()
url3 = f'https://devapi.qweather.com/v7/air/now?location={diqu_id}&key={key}'
resp3 = requests.get(url3, headers=head).json()
url4 = 'http://open.iciba.com/dsapi/'
resp4 = requests.get(url4, headers=head).json()

print("所在地:",resp["location"][0]["adm1"],resp["location"][0]["name"])
print('天气温度:',resp1["now"]["temp"],'  ',resp1["now"]["text"],"\n体感温度:",resp1["now"]["feelsLike"],"\n风向风速风力等级:",resp1["now"]["windDir"],
      '',resp1["now"]["windSpeed"],'',resp1["now"]["windScale"],"\n相对湿度:",resp1["now"]["humidity"],
      "\n大气压强:",resp1["now"]["pressure"],"\n空气质量:",resp3["now"]["category"],'PM2.5',resp3["now"]["pm2p5"],"洗车指数:",resp2["daily"][1]["text"],"\n最近更新时间:",      resp1["updateTime"])
print('')
print(resp4["content"])
print(resp4["note"])

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| milu1123 发表于 2022-8-28 02:26
没人嘛??
unmask 发表于 2022-8-28 15:14
想要给微信发送消息,你要么公众号,要么小程序。再就是利用第三方的一些api接口发送,比如server酱。
requests.post("https://sctapi.ftqq.com/{sckey}.send", params={"title": "消息title", "desp": “消息内容”})
其中的sckey就是在server酱上获取的一个key,这个key就是和微信关联的,具体请参照server酱: https://sct.ftqq.com/
 楼主| milu1123 发表于 2022-8-28 15:38
unmask 发表于 2022-8-28 15:14
想要给微信发送消息,你要么公众号,要么小程序。再就是利用第三方的一些api接口发送,比如server酱。
req ...

微信API接口我有,,不知道怎么去优化了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-16 11:03

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表