Last active
September 20, 2017 13:59
-
-
Save webuti/25ddbe1d9d7126f57629900d707b693c to your computer and use it in GitHub Desktop.
proxy ip port finder api json
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 | |
function getCache($data = false){ | |
$cache_file = 'proxyip.json'; | |
if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 60 * 60))) { | |
$file = file_get_contents($cache_file); | |
} else { | |
if($data){ | |
file_put_contents($cache_file, $data); | |
$file = $data; | |
} | |
} | |
return $file; | |
} | |
function proxyGet() | |
{ | |
if ($cacheData = getCache()) { | |
echo $cacheData; | |
exit; | |
} | |
$datas = file_get_contents('https://www.sslproxies.org/'); | |
$dat = explode('<tr>', $datas); | |
unset($dat[0]); | |
unset($dat[1]); | |
$ip = []; | |
foreach ($dat as $dx) { | |
$dtx = explode('<td>', $dx); | |
$ip [] = [str_replace('</td>', '', $dtx[1]), str_replace('</td>', '', $dtx[2])]; | |
} | |
$sira = rand(0, 99); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'http://www.linkedin.com'); | |
curl_setopt($ch, CURLOPT_HEADER, 1); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); | |
curl_setopt($ch, CURLOPT_PROXY, $ip[$sira][0]); | |
curl_setopt($ch, CURLOPT_PROXYPORT, $ip[$sira][1]); | |
$data = curl_exec($ch); | |
if ($data === false) { | |
proxyGet(); | |
} | |
else{ | |
echo $data = json_encode(['status' => 'ok', 'ip' => $ip[$sira][0], 'port' => $ip[$sira][1]]); | |
getCache($data); | |
} | |
} | |
proxyGet(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment