【转载】python库 js2py (附久邀小脚本)
-
js2py是一个可以让你在python执行JavaScript脚本的库,非常的好玩。
比如 你可以这样写
import js2py js=js2py.EvalJs() js.execute("function writeMessage(){return 'message'}") get_return=js.writeMessage() print(get_return)
这样就可以获取到了JavaScript里边的返回值了,有啥用呢,就是可以让你在写爬虫的时候把包含加密函数的js文件直接加载,然后运行即可。比如loc:
你可以这样写:
def retrun_cookie(): js=js2py.EvalJs() aesjs=requests.get("https://www.hostloc.com/aes.min.js",timeout=5).text js.execute(aesjs) getcookie=requests.get("https://www.hostloc.com/").text getcookie_script=re.findall("<script>(.*?)</script>",getcookie) js.execute(getcookie_script[0].split("document")[0]) data=js.toHex(js.slowAES.decrypt(js.c, 2, js.a, js.b)) cookie="L7FW="+data return cookie
当然使用这个cookie的时候,你得写到header头里面,并且得访问一次https://www.hostloc.com/?d=1
loc登陆的时候需要一个loginhash才能正确登陆。
emm为什么不给完整脚本呢,因为现在好像把检测关了,没法写了
然后附一个爬91的小脚本,总所周知91加密了 拿js加密的
需要安装python3+requests+js2py
- Github地址:https://github.com/eqblog/