Skip to content

Instantly share code, notes, and snippets.

@scumola
Created April 4, 2011 16:31
Show Gist options
  • Save scumola/901922 to your computer and use it in GitHub Desktop.
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
<?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