[Asm] 纯文本查看 复制代码
import json
import random
import requests
import datetime
import keyboard
head = [
{'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2919.83 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2866.71 Safari/537.36'},
{'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux i686 on x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2820.59 Safari/537.36'}]
def main(url):
a = datetime.datetime.now()
today = datetime.date.today()
day_of_week = today.weekday()
c = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'][day_of_week]
time1 = a.strftime(f"%Y年%m月%d日 {c} %H:%M:%S")
b = datetime.datetime(2024, 2, 9)
d = datetime.datetime(2024, 1, 1)
count_down = (b - a).days
count_down1 = (d - a).days
resp = requests.get(url, headers=head[random.randint(0, 9)])
r = json.loads(resp.text)
content = r["content"] + "\n" + r["note"]
print("今天是", time1, "\n", content, "\n", f"距离除夕还有{count_down}天, 元旦还有{count_down1}天")
# info = "今天是"+time+"\n"+content+f"距离除夕还有{count_down}天"
# data = {"method": "sendText", "wxid": "ArayofSunshine1992", "msg": info}
# url = f'http://127.0.0.1:8203/api?json={json.dumps(data)}&key=44468FAE112ACFB7F45643CC5CBC55A5D8DCD006'
# data = {"method": "sendText", "wxid": "Axiaoxiao199996", "msg": info}
# url1 = f'http://127.0.0.1:8203/api?json={json.dumps(data)}&key=44468FAE112ACFB7F45643CC5CBC55A5D8DCD006'
# requests.get(url)
# requests.get(url1)
while True:
if keyboard.is_pressed('esc'):
print("exiting ,program...")
break
if __name__ == '__main__':
url = "http://open.iciba.com/dsapi/"
main(url)