Skip to content

Instantly share code, notes, and snippets.

@johnduhart
Created December 15, 2009 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnduhart/257308 to your computer and use it in GitHub Desktop.
Save johnduhart/257308 to your computer and use it in GitHub Desktop.
<?php
// ProxyGet
// A proxy retrieval script by compwhizii
// Features a lot of regex to get by samair's javascript port hiding
//
// Contact: john@compwhizii.net
$proxies = array();
for ($i=1; $i < 72; $i++) {
echo "Processing page ".$i."...";
if($i < 10) {
$url = "http://www.samair.ru/proxy/ip-address-0".$i.".htm";
} else {
$url = "http://www.samair.ru/proxy/ip-address-".$i.".htm";
}
$page = file_get_contents($url);
//Handle decoding
$code = array();
preg_match_all('/((?:\w=\d;){10}?)/', $page, $rcodes, PREG_PATTERN_ORDER);
$rcodes = $rcodes[0][0];
preg_match_all('/(\w)=(\d);/', $rcodes, $rcodes2, PREG_PATTERN_ORDER);
/*foreach($rcodes2[0] as $line) {
if(preg_match('/(\w)=(\d);/', $line, $regs)) {
$code[$regs[1]] = $regs[2];
}
}*/
preg_match_all('%<tr><td>(?P<ip>(?:[0-9]{1,3}\.){3}[0-9]{1,3})<script type="text/javascript">document\.write\(":"[^<]*?\)</script></td><td>[^<]*?anonymous[^<]*?</td><td>\d{1,3}? minutes ago</td><td>(?P<country>.*?)</td></tr>%', $page, $result, PREG_PATTERN_ORDER);
//$result = $result[1];
foreach($result[0] as $line) {
if (preg_match('%<tr><td>(?P<ip>(?:[0-9]{1,3}\.){3}[0-9]{1,3})<script type="text/javascript">document\.write\(":"(?P<port>(?:\+\w){1,10}?)\)</script></td><td>[^<]*?anonymous[^<]*?</td><td>\d{1,3}? minutes ago</td><td>(?P<country>.*?)</td></tr>%', $line, $regs)) {
$port = $regs['port'];
$port = str_replace('+', '', $port);
$port = str_replace($rcodes2[1], $rcodes2[2], $port);
$proxies[$regs['ip'].":".$port] = $regs['country'];
}
}
echo "Done!\n";
}
$final = array();
foreach($proxies as $ip => $country) {
if(!array_key_exists($country, $final)) {
$final[$country] = array();
}
if(!in_array($ip, $final[$country])) {
$final[$country][] = $ip;
}
}
//print_r($final);
$file = "Proxy List Generated ".date("F j, Y, g:i a")."\n\n";
foreach($final as $country => $ips) {
$file .= "-- ".$country." --\n\n";
foreach($ips as $ip) {
$file .= $ip."\n";
}
$file .= "\n";
}
$fh = fopen('proxies_'.time().'.txt', 'w') or die("can't open proxy file");
fwrite($fh, $file);
fclose($fh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment