Skip to content

Instantly share code, notes, and snippets.

@TennousuAthena
Created April 12, 2022 23:21
Show Gist options
  • Save TennousuAthena/ae635206c8b1afdaf65ad1a1ef745276 to your computer and use it in GitHub Desktop.
Save TennousuAthena/ae635206c8b1afdaf65ad1a1ef745276 to your computer and use it in GitHub Desktop.
从hotokoto自动同步诗词到p.txt
#!/usr/bin/python3
import requests, os, time
while True:
url = "https://v1.hitokoto.cn/?c=i"
response = requests.get(url).json()
file = open('p.txt','w',encoding='utf-8')
file.write(response['hitokoto']+"\n"+response['from_who']+" 《"+response['from']+"》")
file.close()
print(response)
time.sleep(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment