0. Reference 1. Analysis 1.1 Enter the translated content, manually click on the "Translate" button
1.2 View submission data, confirm variance with multiple submissions
1.3 Ctrl+shift+f Global SearchSaltOr SignLocate the three JS code block by searching for the version:2.1 in the submitted data.2.1Lock target code block: Salt timestamp correlation, sign generated by MD5
1.4 Add a breakpoint at the upper function entry, click "Translate" again, F10 start stepping debugging
1.5 Python compute comparison MD5
2. Complete code
Import TimeImportRandomImportReImportHashlibImportRequests fromScrapyImportSelectorurl='http://fanyi.youdao.com/'s=requests. Session () s.headers= { 'Referer':'http://fanyi.youdao.com', 'user-agent':'mozilla/5.0 (Windows NT 6.1; Win64; x64) applewebkit/537.36 (khtml, like Gecko) chrome/66.0.3359.139 safari/537.36'}#Get CookiesR_url =s.get (URL)#Get latest D for MD5 from file Fanyi.min.js#<script type= "Text/javascript" src= "http://shared.ydstatic.com/fanyi/newweb/v1.0.9/scripts/newweb/ Fanyi.min.js "></script>#sel = Selector (text=r_url.text)#url_js = Sel.css (' script::attr (SRC) '). Re_first ('. *fanyi.min.js ' )#R_js = S.get (URL_JS)#D = Re.search (R ' d\s*=\s* "(. *?)" ', R_js.text). Group (1)#print (D)B'ebsefb%=xz%t[kz) C (sy!'Url_post='Http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule'Data=Dict (#i = ' has you eaten ',i ='have you eaten yet? ', #From = ' AUTO ',to ='AUTO', Smartresult='Dict', Client='Fanyideskweb', DOCTYPE='JSON', Version='2.1', Keyfrom='Fanyi.web', Action='fy_by_clickbuttion', Typoresult='false') Salt= str (int (time.time () *1000) + random.randint (0, 9))Print(salt) m=hashlib.md5 () m.update (data['Client']+data['I']+salt+d). Encode ('Utf-8') Sign=m.hexdigest ()Print(sign) data.update ({' from':'AUTO','Salt': Salt,' Sign': Sign}) R_post= S.post (Url_post, Data=data)Print(R_post.json ())
View Code
3. Run the Code
JS Analysis Has _ _ _ _ _ _ Translation MD5