Any idea why would this timeout?

Discussion in 'PHP' started by amorph, Jun 28, 2007.

  1. #1
    function get_pageSource ( $url )
    	{
    		$handle = fopen($url ,'r');
    		$scraped = '';
    	
    		if ($handle) 
    		{
    			while (!feof($handle)) 
    			{
    				$buffer = fgets($handle, 4096);
    				$scraped .= $buffer;
    			}
    			fclose($handle);
    		}
    		
    		return $scraped;
    	}
    
    echo get_pageSource ('http://digg.com/programming');
    
    
    PHP:
    it timeouts only on digg.com, they must have a restriction or something...maybe a better function to trick it?
     
    amorph, Jun 28, 2007 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    Try using curl which gives you control over the user agent and other identifying features.

    Or try taking the while off and make it for($i = 0; $i < $max; $i++) and make $max a small number like 10 and see if it's the connection to digg that is the problem - or what it returns.
     
    sarahk, Jun 28, 2007 IP
  3. amorph

    amorph Peon

    Messages:
    200
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oh well...thanks sarah. I was hoping for something better but I'll have to enable curl on my localhost now and use it. Thanks
     
    amorph, Jun 28, 2007 IP