Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  11] [ 3]  / answers: 1 / hits: 15650  / 14 Years ago, sun, may 2, 2010, 12:00:00

I need to fetch some result on a webpage, which use some JavaScript code to generate the part I am interesting in like following



eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--)d[c]=k[c]||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;}('5 11=17;5 12=[/3/2/1/0/13.4,/3/2/1/0/15.4,/3/2/1/0/14.4,/3/2/1/0/7.4,/3/2/1/0/6.4,/3/2/1/0/8.4,/3/2/1/0/10.4,/3/2/1/0/9.4,/3/2/1/0/23.4,/3/2/1/0/22.4,/3/2/1/0/24.4,/3/2/1/0/26.4,/3/2/1/0/25.4,/3/2/1/0/18.4,/3/2/1/0/16.4,/3/2/1/0/19.4,/3/2/1/0/21.4];5 20=0;',10,27,'40769|54|Images|Files|png|var|imanhua_005_140430179|imanhua_004_140430179|imanhua_006_140430226|imanhua_008_140430242|imanhua_007_140430226|len|pic|imanhua_001_140429664|imanhua_003_140430117|imanhua_002_140430070|imanhua_015_140430414||imanhua_014_140430382|imanhua_016_140430414|sid|imanhua_017_140430429|imanhua_010_140430289|imanhua_009_140430242|imanhua_011_140430367|imanhua_013_140430382|imanhua_012_140430367'.split('|'),0,{}))


The result of eval() is valuable to me, I am writing a Python script, is there any library I can use to virtually run this piece of JavaScript code and get the output?



Thanks


More From » python

 Answers
11

Use a spidermonkey binding



from spidermonkey import Runtime
rt = Runtime()
cx = rt.new_context()
result = cx.eval_script(whatyoupostedabove)

[#96907] Wednesday, April 28, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
terrances

Total Points: 184
Total Questions: 100
Total Answers: 92

Location: Tokelau
Member since Sun, May 7, 2023
1 Year ago
;