java中运行js问题,急求!!!

偏向风雨行 发布于 2015/11/23 14:36
阅读 155
收藏 0
 BufferedReader br = new BufferedReader(new FileReader("src/main/java/com/test/js.txt"));
            StringBuffer sb = new StringBuffer();
            String str = "";


            while ((str = br.readLine()) != null) {
                sb.append(str);
            }


            ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine engine = manager.getEngineByName("js");

            engine.eval(sb.toString());

js代码如下:

<script>var dc="";var t_d={hello:"world",t_c:function(x){if(x==="")return;if(x.slice(-1)===";"){x=x+" ";};if(x.slice(-2)!=="; "){x=x+"; ";};dc=dc+x;}};(function(a){eval(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;}('b d=[6,5,4,2,0,3,1];b o=[];b p=0;g(b i=d.c;i--;){o[d[i]]=a[i]}o=o.m(\'\');g(b i=0;i<o.c;i++){l(o.q(i)===\';\'){s(o,p,i);p=i+1}}s(o,p,o.c);j s(t,r,n){k.h(t.y(r,n))};w("f.e=f.e.v(/[\\?|&]u-x/, \'\')",z);',36,36,'|||||||||||var|length||href|location|for|t_c||function|t_d|if|join||||charAt||||captcha|replace|setTimeout|challenge|substring|1500'.split('|'),0,{}));})(['=/;', 'n, 23-Nov-15 07:25:41 GMT;Path', '%3D;Expires=Mo', '792|0|a3N7QT4K%', '__jsl_clea', '2BkY0ZWRd8I1NBbrdfrE', 'rance=1448259941.']);document.cookie=dc;</script>

这段代码是从网上趴下来的。放在浏览器能运行,在java环境运行就报错,很多变量未定义。。


加载中
返回顶部
顶部