javascript - Regex to get scriptfunction body -


i have document , need function body in document

this piece of document

<script type="text/javascript">   //<![cdata[   (function(){     var = function() {try{return !!window.addeventlistener} catch(e) {return !1} },     b = function(b, c) {a() ? document.addeventlistener("domcontentloaded", b, c) : document.attachevent("onreadystatechange", b)};     b(function(){       var = document.getelementbyid('cf-content');a.style.display = 'block';       settimeout(function(){         var t,r,a,f, vsfcuji={"gqftzuokv":+((!+[]+!![]+!![]+[])+(+[]))};         t = document.createelement('div');         t.innerhtml="<a href='/'>x</a>";         t = t.firstchild.href;r = t.match(/https?:\/\//)[0];         t = t.substr(r.length); t = t.substr(0,t.length-1);         = document.getelementbyid('jschl-answer');         f = document.getelementbyid('challenge-form');         ;vsfcuji.gqftzuokv+=+((+!![]+[])+(!+[]+!![]+!![]));vsfcuji.gqftzuokv+=!+[]+!![]+!![];vsfcuji.gqftzuokv+=+((+!![]+[])+(+[]));vsfcuji.gqftzuokv+=+((!+[]+!![]+!![]+!![]+[])+(+[]));vsfcuji.gqftzuokv-=+((!+[]+!![]+[])+(+[]));a.value = parseint(vsfcuji.gqftzuokv, 10) + t.length;         f.submit();       }, 4000);     }, false);   })();   //]]> </script> 

and need result settimeout(function(){ :

+((!+[]+!![]+!![]+[])+(+[])) 

i use command document

document document = jsoup.connect(encoded_url).timeout(10000).useragent("mozilla/5.0 (compatible, msie 11, windows nt 6.3; trident/7.0;  rv:11.0) gecko").method(connection.method.get).get(); 

then run command function body document.

pattern pattern_1 = pattern.compile("settimeout\\(function\\(\\)\\{\s*.*?.*:(.*?)};");                  matcher m = pattern_1.matcher(document.html()); log.d("matcher", "output:" + m.matches()); 

but gives nothing...

solution proposed wiktor stribiżew

one problem using matches requires full string match. , there lot of lines, , . in case without pattern.dotall won't match newline. , there can unknown number of { , }.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -