shantanu
shantanu

Reputation: 2418

Run Javascript Code

I need to run javascript in php or python or java. My problem is, when a dynamic page load in browser some javascript executes and add some content on html. But if i download the file using wget or any programming language then i can not find the dynamic portion. I am giving you an example:

<html>
   <body>
      <script type="text/javascript" >
         document.body.innerHTML= "hello world";
      </script>
   </body>
</html>

In the above code when i run the code in browser it shows hello world. But if i download the file or open with text editor i will see nothing. So i need to get the output using any programming language. For that i need to execute the javascript. [python,c/c++,php,javascript,java] any language.

Upvotes: 2

Views: 193

Answers (3)

Isaac
Isaac

Reputation: 2721

Apparently Java has it too.

Javax Script Engine

Upvotes: 1

Rich Bradshaw
Rich Bradshaw

Reputation: 72975

You might find the easiest way to use something like Selenium to control a real browser, then to do it that way.

Trying to parse it otherwise will be a problem, as there may be ajax request etc which will cause issues.

Upvotes: 0

Uwe Keim
Uwe Keim

Reputation: 40726

There seems to be a V8 JavaScript Engine Integration inside PHP.

I'm not sure whether this is

  • stable,
  • usable,
  • sensible

at all, but at least it seems this could be an approach for solving your requirement.

Upvotes: 1

Related Questions