import urllib
from urllib import request
import re
url="http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule"
header={"User-Agent":"Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0"}
key="i love big mimi"
fromdata={
'i':key,
'from':'AUTO',
'to':'AUT',
'smartresult':'dict',
'client':'fanyideskweb',
'salt':'15524360928531',
'sign':'d5bbbea7de1d79812b0008c79a8167b5',
'ts':'1552436092853',
'bv':'9d3e032fa834571aa62a09c1b4b8044f',
'doctype':'json',
'version':'2.1',
'keyfrom':'fanyi.web',
'action':'FY_BY_REALTlME',
'typoResult':'false'
}

data=urllib.parse.urlencode(fromdata).encode()
req=request.Request(url,data=data,headers=header)
res=request.urlopen(req).read().decode()

print(res)
#构造正则表达式
pattern='"tgt":"(.*?)"}]]'

result=re.findall(pattern,str(res))
print(result[0])