When you right click here. you will find 'View Page Source' on clicking that, a new window opens with source code of that page.
My question is how would I copy those source code into new file either using javascript , jquery or using php.
When you right click here. you will find 'View Page Source' on clicking that, a new window opens with source code of that page.
My question is how would I copy those source code into new file either using javascript , jquery or using php.
Using jQuery:
$.get( "http://www.example.com/", function( data ) {
console.log(data);
});
Using PHP:
$homepage = file_get_contents('http://www.example.com/');
print_r($homepage);
Reading from a URL and writing to a file:
file_put_contents('example_site.html', file_get_contents('http://www.example.com'));
Note: Make sure you have write permissions in the directory where you are exporting this file to.
To display HTML data without browser rendering it:
$html= "<h1>Hello</h1>";
echo htmlspecialchars($html);