DIGIT-ARC read-only archive · snapshot: July 23, 2026

How to save a web page as HTML using PHP

2 posts · originally from https://geek.digit.in/community/threads/how-to-save-a-web-page-as-html-using-php.111081/

J
jitun Original post #1
Mar 18, 2009 at 1:09 PM
The question is simple i want to save the content of any webpage to simple html so that it can be viewed locally. I can easily get the page content using get_file_content or using curl but the links(a href), scripts and css wont work as they are defined by their relative path in most of the pages. So i wanna to know how to fix those so that the page will work by itself if it is run locally from my system? I suppose they can be fixed using regular expression but i am not very good at regex.


Please Help.
victor_rambo
Mar 18, 2009 at 1:41 PM
You will have to use regex to place the <baseurl> and then write the file to disk using fopen and fwrite.