Advertisement
D3vBl4ck

PHP PROXY SCRAPPER

Jan 2nd, 2020
18,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. $pages = 3;
  2.         $proxies = array();
  3.         for ($page = 1; $page <= $pages; $page++) {
  4.          
  5.           $url = "http://nntime.com/proxy-list-" . sprintf("%02d", $page) . ".htm";
  6.           $response = $curl->get($url);
  7.               $data = $response;
  8.              
  9.               #json_decode($response, true);
  10.          
  11.           if (!empty($data)) {
  12.             $getVars = $this->get_between($data, '</script><script type="text/javascript">', "</script>");
  13.             $getVars = trim(substr($getVars, 0, -1));
  14.             $getVars = explode(";", $getVars);
  15.            
  16.             $variables = array();
  17.             foreach ($getVars as $var) {
  18.               $var = explode("=", $var);
  19.               $variables[$var[0]] = $var[1];
  20.             }
  21.            
  22.             preg_match_all('/onclick="choice\(\)" \/><\/td>(.*?)<\/script><\/td>/si', $data, $getProxies);
  23.             foreach ($getProxies[1] as $proxyRaw) {
  24.               $proxyIP = $this->get_between($proxyRaw, "<td>", "<script type");
  25.               $proxyPort = str_replace("+", "", $this->get_between($proxyRaw, 'document.write(":"+' , ")"));
  26.               $proxyPort = strtr($proxyPort, $variables);
  27.              
  28.               $proxies[] = $proxyIP . ":" . $proxyPort;
  29.             }
  30.           }
  31.         }
  32.         return implode("\n", $proxies);
  33.  
  34. function get_between($content, $start, $end){
  35.         $r = explode($start, $content);
  36.         if (isset($r[1])) {
  37.             $r = explode($end, $r[1]);
  38.             return $r[0];
  39.         }
  40.         return "";
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement