|
发表于 2023-6-17 22:31:20
|
显示全部楼层
import urllib.request as r
import urllib.parse
import time
url = 'https://dict.youdao.com/webtranslate'
data = {}
data['i'] = 'love'
data['from'] = 'auto'
data['to'] = ''
data['domain'] = '0'
data['dictResult'] = 'true'
data['keyid'] = 'webfanyi'
data['sign'] = '5c104ad1542a0efff711269355944ede'
data['client'] = 'fanyideskweb'
data['product'] = 'webfanyi'
data['appVersion'] = '1.0.0'
data['vendor'] = 'web'
data['pointParam'] = 'client,mysticTime,product'
data['mysticTime'] = '1686924739806'
data['keyfrom'] = 'fanyi.web'
data = urllib.parse.urlencode(data).encode('utf-8')
head = {}
head['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36'
while True:
a = input('请输入翻译词汇:(如果按q推出)')
if a == 'q':
break
req = urllib.request.Request(url,data,head)
response = urllib.request.urlopen(req)
html = response.read().decode('utf-8')
print(html)
time.sleep(5)
这就是我的代码运行和提问者一样。 |
|