Downloading Web pages in PHP is simple
$url='https://segmentfault.com/q/1010000000149454'; $data=file_get_contents($url); $target=fopen('/tmp/test.html',"w"); fwrite($target, $data); fclose($target);
The $url is downloaded locally and saved as a/tmp/test.html file.
1. How to save the current page
Enter in the browser
HTTPS://SEGMENTFAULT.COM/Q/10 ...
Open this page
Then, in the console
var content = document.getElementsByTagName ("html") [0].outerhtml;
Content is the contents of this page, how can I use JavaScript to save it in the/tmp/test.html file?
Document.execcommand (' Saveas ', false, '/tmp/test.htm ');
False
2. How do I save any page?
This can be done with PHP above, JavaScript?
Reply content:
Downloading Web pages in PHP is simple
$url='https://segmentfault.com/q/1010000000149454'; $data=file_get_contents($url); $target=fopen('/tmp/test.html',"w"); fwrite($target, $data); fclose($target);
The $url is downloaded locally and saved as a/tmp/test.html file.
1. How to save the current page
Enter in the browser
HTTPS://SEGMENTFAULT.COM/Q/10 ...
Open this page
Then, in the console
var content = document.getElementsByTagName ("html") [0].outerhtml;
Content is the contents of this page, how can I use JavaScript to save it in the/tmp/test.html file?
Document.execcommand (' Saveas ', false, '/tmp/test.htm ');
False
2. How do I save any page?
This can be done with PHP above, JavaScript?
Browser, because of security factors, your requirements are difficult to achieve.
You can consider implementing it in Nodejs.