php - Get the code of a page generated with JavaScript
363
I'm trying to get the code of an URL page after it JavaScript executed.
For the exemple :
<?php
function getVideoURL($link){
$data = file_get_contents($link);
print($data);
}
$link = htmlentities($_POST["link"]);
getVideoURL($link);
?>
But this code give me the code of the url before javasript execution, is there a way to get it after javascript execution ?
Answer
Solution:
file_get_contents get the original code of the page, it doesn't execute any client side code ( javascript )
To execute javascript you will need an entire browser emulation engine -- a headless browser.
http://jonnnnyw.github.io/php-phantomjs/