Skip to content

Instantly share code, notes, and snippets.

@mmeyer2k
Last active May 13, 2019 09:55
Show Gist options
  • Save mmeyer2k/3ebdb11e0bc66b28b073de2b15714ea6 to your computer and use it in GitHub Desktop.
Save mmeyer2k/3ebdb11e0bc66b28b073de2b15714ea6 to your computer and use it in GitHub Desktop.
Archive a webpage to zip
#!/usr/bin/env php
<?php
# read blog posting about this snippet
# https://...
if (!isset($argv[1])) {
exit(1);
}
$scrubbed = preg_replace("/[^A-Za-z0-9 ]/", '', $argv[1]);
`mkdir /tmp/$scrubbed`;
`cd /tmp/$scrubbed ; wget --recursive --html-extension --convert-links --restrict-file-names=windows --no-parent --no-directories --level=1 --span-hosts $argv[1]`;
`7z a -mx9 /tmp/$scrubbed.7z /tmp/$scrubbed/*`;
`rm -rfv /tmp/$scrubbed`;
$d = __DIR__;
`mv /tmp/$scrubbed.7z $d`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment