Youdao translation reptiles

# Youdao translation reptiles
 
** ** today target 

the proper way translation can freely enter content and translate 
`` `Python 
Import Requests
 Import Time
 Import Random
 from hashlib Import MD5 

# Gets TS Sign Salt 
DEF get_salt_sign_ts (Word):
     # TS 
    TS = STR (int (the time.time () * 1000 ))
     # Salt 
    Salt = TS + STR (the random.randint (0,. 9 ))
     # Sign 
    String = " fanyideskweb " + + Salt + Word \
                                " n-A-rKaT5fb% [ Gy;? N5 @ Tj "
    s = md5()
    s.update(string.encode())
    sign = s.hexdigest()

    return salt,ts,sign

# 破解有道翻译
def attack_yd(word):
    salt,ts,sign = get_salt_sign_ts(word)
    # url地址为: F12->Headers->General->Request URL
    url = 'http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule'
    # headers
    headers = {
        "Accept": "application/json, text/javascript, */*; q=0.01",
        # "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Connection": "keep-alive",
        "Content-Length": "238",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "Cookie": "[email protected]; OUTFOX_SEARCH_USER_ID_NCOO=1492587933.976261; JSESSIONID=aaa5_Lj5jzfQZ_IPPuaSw; ___rl__test__cookies=1559193524685",
        "Host": "fanyi.youdao.com",
        "Origin": "http://fanyi.youdao.com",
        "Referer": "http://fanyi.youdao.com/",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
        "X-Requested-With": "XMLHttpRequest",
    }
    # data: FormData为字典
    data = {
        "i": word,
        "from": "AUTO",
        "to": "AUTO",
        "smartresult": "dict",
        "client": "fanyideskweb",
        "salt": salt,
        "sign": sign,
        "ts": ts,
        "bv": "f4d62a2579ebb44874d7ef93ba47e822",
        "doctype": "json",
        "version": "2.1",
        "keyfrom": "fanyi.web",
        "action": "FY_BY_REALTlME",
    }

    proxies = {
        'http': 'http://475199896:[email protected]:16818',
        'https': 'http://475199896:[email protected]:16818',
    }

    html_json = requests.post(
        url = url,
        data = data,
        headers = headers,
        proxies=proxies
    ) .json () 
    #html_json: 
    # 'translateResult': [[{ 'TGT': 'Hello', 'the src': 'Hello'}]] 
    Result = html_json [ ' translateResult ' ] [0] [0] [ ' TGT ' ] 

    return Result 

IF  __name__ == ' __main__ ' : 
    Word = the iNPUT ( ' enter word to be translated: ' ) 
    the Result = attack_yd (Word)
     Print (the Result) 

`` `

 

Guess you like

Origin www.cnblogs.com/cxiaolong/p/11241305.html