data = {"inputtext": "下雨了", "type": "AUTO"} headers = {"User-Agent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Mobile Safari/537.36"}
r = requests.post("http://m.youdao.com/translate",data=data,headers=headers)
运行结果:
找到一个适合初级玩家的翻译接口*
360翻译接口,类似于百度翻译接口。可以用来练习json串处理。
代码如下:
1 2 3 4 5 6 7 8 9 10
import requests import json
data = {"eng": "0", "query": "下雨了"} headers = {"User-Agent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Mobile Safari/537.36"}
r = requests.post("https://fanyi.so.com/index/search",data=data,headers=headers) result = json.loads(r.content.decode())["data"]["fanyi"] print(result)