(新手入门)一个简单的天气提醒python代码
import requestsfrom bs4 import BeautifulSoup
# 本推送使用Qmsg酱
qmsg_code = 'https://qmsg.zendee.cn/send/您的KEY?msg='
# china/hong-kong/hong-kong-island-此字节可以根据实际需求做出更改
url = 'https://tianqi.moji.com/weather/china/hong-kong/hong-kong-island-'
# resp函数定义了对url的请求数据
resp = requests.get(url).text
# soup将resp获取数据进行以'lxml'形式的处理
soup = BeautifulSoup(resp, 'lxml')
# 在soup中查找天气信息
description = soup.find(attrs={"name": "description"})['content']
# 信息推送进行重组
weather_notify = qmsg_code + description
# 执行发送动作
weather_message_send = requests.get(weather_notify)
感谢分享代码 感谢分享 谢谢分享 感谢分享源码 谢谢楼主的分享
感谢分享,正好需要天气提醒
页:
[1]