admin管理员组

文章数量:1384563

I have a very big HTML page with many large tables. I have tried to export the tables to excel and succeeded. But when dealing with 200K+ rows in a table, the browser crashes (Chrome and IE). So, I have decided to save the entire page locally.

Can it be done?

Thanks

I have a very big HTML page with many large tables. I have tried to export the tables to excel and succeeded. But when dealing with 200K+ rows in a table, the browser crashes (Chrome and IE). So, I have decided to save the entire page locally.

Can it be done?

Thanks

Share Improve this question edited Jan 5, 2017 at 13:09 GôTô 8,0633 gold badges36 silver badges45 bronze badges asked Jan 5, 2017 at 12:40 ZarofZarof 1172 silver badges12 bronze badges 4
  • 2 File -> Save Page As? – Serg Chernata Commented Jan 5, 2017 at 12:41
  • what exactly do you want to save? just the raw HTML code? or the whole page including images, css, js? – vsync Commented Jan 5, 2017 at 12:56
  • Whole page locally.. – Zarof Commented Jan 5, 2017 at 13:03
  • @SergChernata exactly the same as File -> Save Page As... – Zarof Commented Jan 5, 2017 at 13:09
Add a ment  | 

4 Answers 4

Reset to default 1

If you need a download button that anyone can use on your site to save a file, use the download attribute.

<a href='link.html' download>text</a>

I suppose that the data that is in these tables is loaded from your server somewhere. Wouldn't it be better to create a downloadlink to an action on your server that creates these files instead of creating the files based on your html page?

One solution is to load the page in your browser and then go to File > Save As. This will open a dialoge that allows you to save the page as an html type file.

However if the webpage is so large that the browser cannot load it, use a tool like wget on linux to pull the entire page down without using a browser. After installing wget on a linux distribution, use it like so

wget http://www.example./path/to/file.html

This mand will download the file to the current directory with name file.html

If you also want to download any included files in file.html (ie css or js files). Include the flags -p and -k.

I created a file called download-page-test.html as seen below.

<html>
<head>
    <title>Template</title>
    <link href="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
    <h1>Look at this page.</h1>
    <h1>It's so plain!</h1>
    <a class="btn btn-primary" href='/download-page-test.html' download>Click Here to Download</a>
</body>

When the user clicks on the word "text", the browser downloads the same exact file that is served to the browser as well as the JS/CSS for the page (Granted you don't move/delete the external resources). Note: I used BootStrap to make it look a bit nicer.

This solution is for a page that loads in the browser successfully and the user wants a copy.

本文标签: javascripthow can i save the current HTML page locally via a button on pageStack Overflow