Advertisement
Guest User

Untitled

a guest
Oct 27th, 2012
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2.  
  3.     $var = fread_url("http://www.entendu.info");
  4.            
  5.     preg_match_all ("/a[\s]+[^>]*?href[\s]?=[\s\"\']+".
  6.                     "(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/",
  7.                     $var, &$matches);
  8.        
  9.     $matches = $matches[1];
  10.     $list = array();
  11.  
  12.     foreach($matches as $var)
  13.     {    
  14.         print($var."<br>");
  15.     }
  16.  
  17.    
  18.    
  19.    
  20.    
  21.    
  22.  
  23. // The fread_url function allows you to get a complete
  24. // page. If CURL is not installed replace the contents with
  25. // a fopen / fget loop
  26.  
  27.     function fread_url($url,$ref="")
  28.     {
  29.         if(function_exists("curl_init")){
  30.             $ch = curl_init();
  31.             $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; ".
  32.                           "Windows NT 5.0)";
  33.             $ch = curl_init();
  34.             curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  35.             curl_setopt( $ch, CURLOPT_HTTPGET, 1 );
  36.             curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  37.             curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
  38.             curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
  39.             curl_setopt( $ch, CURLOPT_URL, $url );
  40.             curl_setopt( $ch, CURLOPT_REFERER, $ref );
  41.             curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  42.             $html = curl_exec($ch);
  43.             curl_close($ch);
  44.         }
  45.         else{
  46.             $hfile = fopen($url,"r");
  47.             if($hfile){
  48.                 while(!feof($hfile)){
  49.                     $html.=fgets($hfile,1024);
  50.                 }
  51.             }
  52.         }
  53.         return $html;
  54.  
  55.     }
  56.    
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement