Skip to content

Instantly share code, notes, and snippets.

@ammarfaizi2
Created October 13, 2018 06:36
Show Gist options
  • Save ammarfaizi2/387afd04847ebfedeb3fbf0768c1ba60 to your computer and use it in GitHub Desktop.
Save ammarfaizi2/387afd04847ebfedeb3fbf0768c1ba60 to your computer and use it in GitHub Desktop.
<?php
$typeProxy = 'http'; //http/socks
if ($typeProxy === 'http') {
$url = 'https://free-proxy-list.net/';
} else if($typeProxy === 'socks') {
$url = 'https://www.socks-proxy.net/';
}
$get = curl($url);
// preg_match_all('/<tr><td>([0-9.]+)<\/td><td>([0-9]+)<\/td>/', $get, $result);
// preg_match_all('/<td class=\'hm\'>([A-Za-z]+)<\/td>/', $get, $match);
// print '<pre>'.print_r($match,1).'</pre>';
preg_match_all("/(?:<tr>.+<td class='hm'>)(.*)(?:<)/Usi", $get, $m);
print '<pre>'.print_r($m[1], 1).'</pre>';
function curl($url, $data=null, $ua=null, $cookie=null) {
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
if($data != null){
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $data);
}
// curl_setopt($c, CURLOPT_PROXY, '118.171.222.103:3128');
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
if($cookie != null){
curl_setopt($c, CURLOPT_COOKIE, $cookie);
}
if($ua != null){
curl_setopt($c, CURLOPT_USERAGENT, $ua);
}
$hmm = curl_exec($c);
curl_close($c);
return $hmm;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment