Python SpiderMonkey Navigator
If you are trying to do JS in python, you’re going to run into many hurdles. The python javascript project, that I know of, is python-spidermonkey. The project lacks a few important object; document, window, navigator. Fortunately, there are those of us who have added to the project, and made these modules available, at least in some capacity.
You can find the document and window objects on Didier Stevens’ blog (link below). He’s done an excellent job at porting these modules over to spidermonkey.
I’ve put together a very rudimentary navigator object. The values are hard-coded, but the object makes you appear to be running Firefox on a Mac. If you’d like to change the code in anyway, be my guest. I was unable to find a port of this object, so I created on from scratch.
I’ve included all of the configuration files that you will need to work with Didier Stevens’ objects and my own. You need to visit Didier Steven’s blog to download his code.
Go to http://wwwsearch.sourceforge.net/python-spidermonkey/ and download/untar the project
Go to http://blog.didierstevens.com/programs/spidermonkey/ and follow his instructions
Download BlackCodeSeo Navigator.
Run python setup.py install
Python-SpiderMonkey Implemeting Navigator
>>>
>>> rt = Runtime()
>>> cx = rt.new_context()
>>>
>>> print cx.eval_script('navigator.appCodeName;')
Mozilla
>>> print cx.eval_script('navigator.appName;')
Netscape
>>> print cx.eval_script('navigator.appVersion;')
5.0 (Macintosh; en-US)
>>> print cx.eval_script('navigator.cookieEnabled;')
0
>>> print cx.eval_script('navigator.language;')
en-US
>>> print cx.eval_script('navigator.mimeTypes;')
None
>>> print cx.eval_script('navigator.platform;')
MacIntel
>>> print cx.eval_script('navigator.plugins;')
None
>>> print cx.eval_script('navigator.systemLanguage;')
undefined
>>> print cx.eval_script('navigator.userAgent;')
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3
>>> print cx.eval_script('navigator.userLanguage;')
en-ca
>>> print cx.eval_script('navigator.javaEnabled();')
0

Leave a comment
You must be logged in to post a comment.