话说我在研究pywhatkit
时搞了一下源程序,发现了这个:
data = requests.get(
f"https://pywhatkit.herokuapp.com/handwriting?text={string}&rgb={rgb[0]},{rgb[1]},{rgb[2]}"
)
然后,我掏出了apifox
,一试:
ohhhhhhhhhhh !
来,说说我发现的东西!
这是一个GET请求的API接口
,两个参数,分别是text
(文字)和rgb
(颜色)。
我找了一段简短的英文小故事来测试。接口无法处理中文。
A child was careless ramie stabbed, he rushed home and told his mother: I only lightly Pengyi what, it was my painful thorns.Mom said: Because of this, it will thorn you. if the next time you met Ramie, to a courageous and seize it, it will be in your hands become soft as silk, you will no longer be stabbed.It is said that many people are serving hard against soft.
我把它写成一个程序,一起来看:
from requests import get
t = input('Enter some English >>> ')
if len(t) > 1035:
print('The content you entered is too long.')
input()
exit()
color = (30,30,150)
params = {
'text':t,
'color':'%d,%d,%d' % (color[0],color[1],color[2])
}
try:
res = get('https://pywhatkit.herokuapp.com/handwriting',params=params)
with open('text.png','wb') as f:
f.write(res.content)
print('\nSuccessful production.')
input()
except Exception as e:
print('Error :',e)