马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
索引限度好像有问题,输入词汇的话可以正常搜出来,但是句子就不行了import urllib.request
import urllib.parse
import json
shuru = input("请输入翻译内容:")
url = "https://fanyi.sogou.com/reventondc/suggV3"
head = {}
head["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3947.100 Safari/537.36"
data = {}
data["from"] = "auto"
data["to"] = "zh-CHS"
data["client"] = "wap"
data["text"] = shuru
data["uuid"] = "7baa26ff-740a-4ed1-bb1e-bb56a8001c4c"
data["pid"] = "sogou-dict-vr"
data["addSugg"] = "on"
data = urllib.parse.urlencode(data).encode("utf-8")
req = urllib.request.Request(url,data,head)
response = urllib.request.urlopen(req)
html = response.read().decode("utf-8")
target = json.loads(html)
c = target["sugg"][0]["v"]
d = c[1:]
print("翻译结果:%s" % d)
|