tags:

views:

159

answers:

4

Hi All,

I am dealing with a problem where I need to do few thing at the SERVER SIDE using JAVASCRIPT (I am using php + apache combination )-

  1. read source of url using curl
  2. run it through some server side JavaScript and get DOM out of it
  3. traverse and parse the DOM using pre-existing java script code.This code works fine in a browser.

I goggled and found http://pecl.php.net/package/spidermonkey , which allows us to run java script at server.is there any better way to achieve this? can we use Mozilla engine to get DOM out of HTML source code and process it using java script ?

Thanks in advance

+1  A: 

PHP contains a DOM parser - I would recommend using this to achieve the same results, rather than using server-side Javascript.

Tom Woolfrey
The "pre-existing java script code" mentioned in the question might be a bit more complex.
VolkerK
A: 

You might want to use something else than Javascript, but if you really need this, you can run firefox under Xvfb and remote connect to it from php. It's not exactly trivial to set up, but it's possible.

You might want to try with something like SimpleBrowser instead.

troelskn
+1  A: 
Sinan Y.
A: 

You might want to try installing GromJS. But the success depends on complexity of your JS code. As far as I see, GromJS does not have DOM :(

A lot more complex project, Narwhal does have DOM and a lot more.

For more information, refer to Mozilla hub about ServerJS.

warpech