Created
August 25, 2012 17:05
-
-
Save NetworksAreMadeOfString/3467995 to your computer and use it in GitHub Desktop.
Simple Reading Bus Stop short code
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
$StopCode = array(0 => 'a', 1 => 'a', 2 => 'a',3 => 'a'); | |
$ValidStops = array(); | |
$ch = curl_init(); | |
for($a = 0; $a < 26; $a++) | |
{ | |
for($b = 0; $b < 26; $b++) | |
{ | |
for($c = 1; $c < 26; $c++) | |
{ | |
for($d = 1; $d < 26; $d++) | |
{ | |
$ShortCode = 'rdg' . $StopCode[0] . $StopCode[1] . $StopCode[2] . $StopCode[3]; | |
if(GetStop($ch, $ShortCode)) | |
{ | |
$ValidStops[] = $ShortCode; | |
//sleep(1); | |
usleep(10000); | |
} | |
else | |
{ | |
//usleep(10000); | |
} | |
$StopCode[3]++; | |
} | |
$StopCode[2]++; | |
$StopCode[3] = 'a'; | |
} | |
$StopCode[1]++; | |
$StopCode[2] = 'a'; | |
} | |
$StopCode[0]++; | |
$StopCode[1] = 'a'; | |
} | |
print_r($ValidStops); | |
function GetStop($ch, $ShortCode) | |
{ | |
//$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "http://www.mytraveline.mobi/WebView/BusStopSearch/BusStopSearchResults/".$ShortCode); | |
curl_setopt($ch, CURLOPT_HEADER,0); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$data = curl_exec($ch); | |
if(stristr($data, 'There has been a problem processing your request') === FALSE) | |
{ | |
print($ShortCode . " : Success\r\n"); | |
return true; | |
} | |
else | |
{ | |
//print($ShortCode . " : Failed\r\n"); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment