Saving Website HTML, JS, and CSS with PHP
I have a list of websites that I would like to save locally and they have external CSS and JS that I really want living in one folder. wget has an overwhelming amount of options so this can be done pretty easily. Now, I still want to hit a url to do this, not from command line, so I will use the php exec command.
In terms of the options, I am going to use -p –convert-links in order to save HTML, JS, and CSS resources and convert the links in the HTML page so they are referenced accordingly. This gives me crappy directory structure, however, so I also use the -nd option to disable the creation of directories when retrieving recursively. Finally, -P downloads is going to save the website I just scraped into the downloads directory. Pretty neat.
Here you can learn more about wget commands. And, here is the code: