杨某某12138 发表于 2021-4-21 17:11:27

搜狗翻译爬虫问题

索引限度好像有问题,输入词汇的话可以正常搜出来,但是句子就不行了
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"]["v"]
d = c
print("翻译结果:%s" % d)

龙舞九天 发表于 2021-5-9 20:20:22

{:5_106:}
页: [1]
查看完整版本: 搜狗翻译爬虫问题