Python爬取有道翻译(破解加密--js加密)( 二 )

2.完整代码import requestsimport timeimport randomimport hashlibfrom pprint import pprintdef main():"""主程序"""url = ";smartresult=rule"headers = {'X-Requested-With': 'XMLHttpRequest','User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36','Origin': '','Referer': '/','Cookie': 'OUTFOX_SEARCH_USER_ID=-1808168645@10.108.160.208; JSESSIONID=aaaRyVJv8oEwg7dPaWrux; OUTFOX_SEARCH_USER_ID_NCOO=704285648.1294403; ___rl__test__cookies=1602406917270'}i = input(">")data = http://kandian.youth.cn/index/get_data(i)response = requests.post(url=url,headers=headers,data=data)print(response.json()["translateResult"][0][0]["tgt"])def do_md5(content):"""md5方法"""md5 = hashlib.md5()md5.update(content.encode("utf-8"))return md5.hexdigest()def get_data(i):"""获取参数"""lts = str(round(time.time(), 3)).replace(".", "")salt = lts + str(random.randint(0, 9))sign = do_md5("fanyideskweb" + i + salt + "]BjuETDhU)zqSxf-=B#7m")data = http://kandian.youth.cn/index/{'action': 'FY_BY_CLICKBUTTION','bv': '9caf244986fe6d1de38207408302e500','client': 'fanyideskweb','doctype': 'json','from': 'AUTO','i': i,'keyfrom': 'fanyi.web','lts': lts,'salt': salt,'sign': sign,'smartresult': 'dict','to': 'AUTO','version': '2.1'}return dataif __name__ == '__main__':main()3.结果
Python爬取有道翻译(破解加密--js加密)文章插图
PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取
完整代码可以点击下方链接获取~
【Python爬取有道翻译(破解加密--js加密)】python免费学习资料以及群交流解答后台私信小编01


推荐阅读