介绍
使用库
requests # 抓取诗词
pyautogui # 抓取鼠标位置
pyperclip # 复制内容
代码
# coding=utf-8
import time
import os
import requests
import pyautogui as pag
import pyperclip
def get_content():
url = "https://v2.jinrishici.com/one.json?client=browser-sdk/1.2&X-User-Token=GZ4OvuURfJWgEoGnsiSu3xpdeEOboSVf"
response = requests.request("GET", url)
content = response.json().get("data", {}).get("content")
return content
try:
time.sleep(5)
x, y = pag.position()
print(f"Position:{x},{y}")
time.sleep(1)
os.system('cls')
n = 1
print('start....')
while True:
line = get_content()
if line:
print(f"发送第{n}次,内容为:{line}")
pag.click(x, y)
pyperclip.copy(line)
pag.hotkey("ctrl", "v")
pag.typewrite("\n")
time.sleep(1)
n += 1
except KeyboardInterrupt:
print('end....')