Downloading HTML from a page

Asked

Viewed 650 times

-5

I would like to know a way or plugin that helps me to download the HTML of the page in format .html. My goal is to make it possible to edit images and texts in an image and finally to download it. I tried to use the download.js http://danml.com/download.html. But this, just let me download the HTML body, obviously it would be my intention to download the whole body, alternatively, in PHP I discovered this page: https://davidwalsh.name/create-zip-php. Where the files are downloaded as .zip. I’m using wamp, but I don’t know how to run this function to download the files...

Here’s an example of the page I need to download

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Ola mundo</title>
</head>
<body>
    <p>Esta é uma página que pode ser baixada</p>
    <p>2019@</p>
</body>
</html>

1 answer

0

I found the best answer on this link:

https://stackoverflow.com/questions/13080943/download-php-generated-webpage-as-html-file

by far the most elegant way to download HTML using php.

<?php

 //Link to download file...
 $url = "http://example.com/test.php";

 //Code to get the file...
 $data = file_get_contents($url);

 //save as?
 $filename = "test.html";

 //save the file...
 $fh = fopen($filename,"w");
 fwrite($fh,$data);
 fclose($fh);

 //display link to the file you just saved...
 echo "<a href='".$filename."'>Click Here</a> to download the file...";

?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.