Created
April 4, 2011 16:31
-
-
Save scumola/901922 to your computer and use it in GitHub Desktop.
php code that will emulate a fake site to test a web crawler with. Can increase the size of the fake site using the depth=x variable
This file contains hidden or 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 | |
$depth=$_GET['depth']; | |
$numurls=$_GET['numurls']; | |
$code =$_GET['code']; | |
if (!isset($numurls)) { | |
$numurls=100; | |
} | |
if (!isset($depth)) { | |
$depth=2; | |
} | |
function genRandomString() { | |
global $depth; | |
$length = $depth; | |
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
$string = ''; | |
for ($p = 0; $p < $length; $p++) { | |
$string .= $characters[mt_rand(0, strlen($characters)-1)]; | |
} | |
return $string; | |
} | |
$a = 0; | |
while ($a < $numurls) { | |
$newcode = genRandomString(); | |
print ("<a href='crawlme.php?numurls=$numurls&depth=$depth&code=$newcode'>$newcode</a> "); | |
$a++; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment