2

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.

1
  • Why do you need the dynamically generated document source? Commented Feb 26, 2012 at 8:45

3 Answers 3

1

Apparently Java has it too.

Javax Script Engine

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.