Code download page and execution of the JS change the HTML code in php. There are ready solutions?

I need to download the code of a certain page and using the class DOMDocument to parse it and get the desired information.
The problem is that the method of the DOMDocument->loadHTMLFIle () and the function file_get_contents only load the HTML in the form in which it is returned from the server and information that I need is loaded additionally with JS.
Is there a php ready-made solution that not only downloads the HTML source, but will perform the JS (in the events window.onload and similar) and return already changed the HTML, which is displayed in the browser when the page is opened?
July 2nd 19 at 18:24
2 answers
July 2nd 19 at 18:26
And how to use it? Besides the examples on JS, I found nothing. - Gage94 commented on July 2nd 19 at 18:29
: here it is: blog.luchnikov.ru/programming/phantomjs - nicklaus.Will commented on July 2nd 19 at 18:32
: Not bad. While the decision will not mark it, suddenly something else will offer. Later I note, along with other options. - Gage94 commented on July 2nd 19 at 18:35
: Fantom not suitable - we do not server, and a very limited hosting. And hardware server a lot weaker than you need. - Gage94 commented on July 2nd 19 at 18:38
: then no way. - cesar.Muller commented on July 2nd 19 at 18:41
: Well in that case You will likely not get a full parse dynamic websites.

If we are talking about specific units that are loaded with AJAX, you can watch the link to knocks site and directly obtain information. Ie to make a direct request for the desired resource. - nicklaus.Will commented on July 2nd 19 at 18:44
: will not go. Of sites more than 70 pieces. Plus, the client should be able to just specify the website address and the script should still be fine to parse. Actually, the problem is the execution of JS. - Gage94 commented on July 2nd 19 at 18:47
July 2nd 19 at 18:28
You understand that in order to execute JS code in PHP, you need a JS engine written in either PHP or embedded in it. Version of the JS engine written entirely in PHP I'm not considering at all, since it would be complete insanity, and from the point of view of effort and from the point of view of performance and end result. Accordingly, there is the option to use the solution, which was built in PHP... but, such a solution with 99% probability will not be available on shared hosting, but it can be installed on a local VPS or dedicated server.

One of the most popular JS-engine is a V8, carved out of Google Chrome, in particular, is its implementation for PHP, probably someone has already tried to write something similar (to mix PHP and JavaScript to get a kind of browser)...

But I would probably try to start from something more simple (in implementation) of the options, in particular, would look the commands and/or plugins for the browser that would allow to keep the code of the entire page to HTML file, running at the same time from the command line, or tried to write a script for the browser (JS), which would be inserted into the end of the page (for example, using a simple proxy that you can write on the same PHP or fiddle with Nginx/Apache) would take current HTML code directly from your browser, after it changes and send it in finished form to a PHP script, which after parsing, gave the address of the next page in the same script, and so on ad infinitum (or until the desired page is not going to end).

Find more questions by tags PHPHTML