Last active
May 13, 2019 09:55
-
-
Save mmeyer2k/3ebdb11e0bc66b28b073de2b15714ea6 to your computer and use it in GitHub Desktop.
Archive a webpage to zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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