VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > python爬虫 >
  • Python爬虫连载8-JS加密(一)

一、JS加密

1.有的反爬虫策略采用js对需要传输的数据进行加密处理。

2.经过加密,传输的就是密文

3.加密函数或者过程一定是在浏览器完成,也就是一定会把代码(js代码)暴露给使用者

4.通多阅读加密算法,就可以模拟出加密过程,从而达到破解。

5.举一个案例

 

复制代码
"""

破解有道词典

"""

from urllib import request,parse

​

def youdao(key):

    url = "http://www.fanyi,com/translate_o?smartresult=dict&smartresult=rule"

    data = {

        "i":"girl",

        "from":"AUTO",

        "to":"AUTO",

        "smartresult":"dict",

        "client":"fanyideskweb",

        "salt":"1523100789519",

        "sign":"b8a55a436686cd89873fa46514ccedbe",

        "doctype":"json",

        "version":"2.1",

        "keyfrom":"fanyi.web",

        "action":"FY_BY_REALTIME",

        "typeResult":"False"

    }

​

    data = parse.urlencode(data).encode()

    headers = {

        "Connection": "keep - alive",

        "Content - Encoding":"gzip",

        "Content - Language": "zh - CN",

        "Content - Type": "text / html",

        "charset":"utf - 8",

        "Date": "Mon, 17 Feb 2020 15: 23:36 GMT",

        "Server":"nginx",

        "Transfer - Encoding": "chunked",

        "Vary": "Accept - Encoding"

    }

    req = request.Request(url=url,data=data,headers=headers)

​

    rsp = request.urlopen(req)

​

    html = rsp.read().decode()

    print(html)

​

if __name__ == "__main__":

    # for i in range(10000):

    #     print(sum)

youdao(45)
复制代码

 

 

二、源码

Reptitle8_1_JSEncryption.py

https://github.com/ruigege66/PythonReptile/blob/master/Reptitle8_1_JSEncryption.py

2.CSDN:https://blog.csdn.net/weixin_44630050

 

出  处:https://www.cnblogs.com/ruigege0000/p/12324518.html


相关教程