如何使用python的execjs模块运行javascript的自调用函数

2020-07-29 17:29发布

问题:

(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p})('q g=g=\'["n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/m.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/p.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/r.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/s.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/k.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/h.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/i.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/j.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/l.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/o.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/D.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/A.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/B.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/C.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/E.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/z.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/y.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/u-t.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/v.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/w.5","n\\/%0%6%4%0%1%7%8%3%2%0%1%a\\/%d%f%e%b%c%9\\/x.5"]\';',41,41,'E5|8F|90|88|B3|jpg|A5|8B|E6|9D|8C|E8|AF|E7|AC02|AC|pages|43|44|45|42|46|38||47|39|var|40|41|056|055|057|058|059|054|053|049|050|051|048|052'.split('|'),0,{})

就是这串代码,如何使用execjs去运行?求大佬给出详细代码

回答1:

你说一下你运行这段js你入参是什么,调用js中哪个方法

js_obj = execjs.compile('你上述的js 代码')
res = execjs.call('方法名',入参)
#这个模块很久没跟新了不建议使用
#推荐直接nodejs运行js