赞
踩
import json import requests def fangYi(data1): url = "https://fanyi.baidu.com/sug" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0 Win64 x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" } data = {"kw": data1} r = requests.post(url=url, headers=headers, data=data).content.decode() j = json.loads(r) if j['errno'] == 0: try: v = j['data'][0]['v'] print(v + "\n") except: print('falied,try again!!!\n') if __name__ == '__main__': while True: data1 = input("press q quit:\n") if data1 == "q": break else: fangYi(data1)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。