View Single Post
Old 05-04-2009, 11:13 PM  
ProG
Confirmed User
 
Join Date: Apr 2009
Posts: 1,319
Yes, it creates the full text file before writing it. You could write each time but at 5000+ times that could cause some issues. Unless absolutely necessary, I wouldn't do it that way. Here is the code anyways..

PHP Code:
<?php
    $search 
"google"// Your seach string
    
    
if ( ( $websites file"websites.txt" ) ) !== false )
    {
        foreach( 
$websites as $url )
        {
            
$url trim$url );
            
$contents file_get_contents$url );
            if ( ( 
strpos$contents$search ) ) !== false )
            {
                if ( ( 
$handle fopen"valid.txt"'at' ) ) !== false )
                {
                    
fwrite$handle"{$url}\n" );
                    
fclose$handle );
                }
            }
            else
            {
                if ( ( 
$handle fopen"bad.txt"'at' ) ) !== false )
                {
                    
fwrite$handle"{$url}\n" );
                    
fclose$handle );
                }
            }
            
sleep10 ); // 10 second timeout between URLs
        
}
    }
?>

Last edited by ProG; 05-04-2009 at 11:16 PM..
ProG is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote