python 调用js

 python调用js脚本。首先安装PyExecJS

import execjs

def get_js():
    f = open("tongchengJS.js", 'r', encoding='utf-8')
    line = f.readline()
    htmlstr = ''
    while line:
        htmlstr = htmlstr+line
        line = f.readline()
    return htmlstr


def get_des_psswd(e):
    js_str = get_js()
    ctx = execjs.compile(js_str)
    return (ctx.call('antitoken', e))


print(get_des_psswd(e='1570243707293'))

  

原文地址:https://www.cnblogs.com/guohu/p/13565740.html