D
D
Dmitry Nesterov2021-06-13 19:07:14
PHP
Dmitry Nesterov, 2021-06-13 19:07:14

How to view the code of a site that has one connection to a JS file?

Is it possible to view code in PHP from another site that has one connection to JS? For example:

<html>
<body>
<script src="script.js"></script>
</body>
</html>

It is necessary to get the content of the site, and not this code. Is it possible? Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yuriev, 2021-06-13
@dyuriev

I can offer you an interesting crutch through chrome / chromium, install
chromium and call it through shell_exec with the parameters headless / disable-gpu / dump-dom (the last flag is key for your task).
more or less like this:

$dom = shell_exec('chromium-browser --headless --disable-gpu --dump-dom https://example.ru/');

replace chromium-browser with the name of the chromium(ium) binary, and in the distribution
, in this case, chromium(ium) will start in headless mode (without a user graphical interface), without gpu support (they don’t have one hell of a thing on servers with rare exceptions), download page, all resources, will perform the entire Client-Slide-render (just this JS script), collect the DOM and return it (the collected DOM )
as a result but it's a long time to tell PPS: not through browsers / browser engines, implementation in pure PHP is extremely difficult, to put it mildly, because at least you will have to interpret JS in some way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question