0

i've tried some of the most known html-parsers in php like simpletest , simplehtmldom and domdocument

but none of them parse javascript.I know that javascript is client side language that can only be executed in the browser so, i was wondering if there is a website that provide free api for html parsing with javascript enabled (you send them the html source and they return the source after the execution of all javascripts in the page)

1
  • You could use PhantomJS locally or on your own remote server. There might be a third party option, but it would be trivial enough to run yourself. Commented Jul 14, 2014 at 19:41

2 Answers 2

1

What do you want to achieve?

For doing stuff like testing and automation headless, PhantomJS should do the job. You can even download a page, execute the JS on the page and then convert it to a PNG. But it's not an API, it's a program that you have to install locally :-)

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

Comments

0

You want something to show html after it's been changed by javascript - unless I've understood incorrectly, this is just a browser.

Try opening your document with your chosen browser: It will load all the html, and carry out any javascript that isn't contained within a function. You will probably only want the javascript to execute once the HTML has finished loading, so you could put a script tag at the bottom of the page

Alternatively, and perhaps better practice, try setting up an initialisation function, which is called once the page has finished loading.

<html>
    <head>
    <script>
        function init(){
            // resize page depending on pixels or something
        }
    </script>
    </head>
    <body onLoad="init()">

    </body>
    <script>
    // javascript goes here
    </script>
</html>

If you are looking for some sort of debugging, there are a few options out there, including ones within browsers.

Chrome

Firefox

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.