Created
September 22, 2012 15:27
-
-
Save ralphschindler/3766520 to your computer and use it in GitHub Desktop.
Script to be used with PHP's built-in webserver to proxy and spider a site on click
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
<?php | |
// start PHP with: php -S localhost:8888 -t . spider.php | |
$site = 'http://www.targetwebsite.org/'; | |
$path = $_SERVER["REQUEST_URI"]; | |
if ($path == '/') { | |
$path = '/index.html'; | |
} | |
if (file_exists(__DIR__ . $path)) { | |
return false; | |
} | |
$content = file_get_contents($site . $path); | |
if (strpos(ltrim($path, '/'), '/')) { | |
if (!file_exists(__DIR__ . dirname($path))) { | |
mkdir(__DIR__ . dirname($path), 0777, true); | |
} | |
} | |
file_put_contents(__DIR__ . rawurldecode($path), $content); | |
sleep(1); | |
return false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment