Тема: goog
Показать сообщение отдельно

  #12  
Старый 31.07.2007, 09:24
KEZ
Banned
Регистрация: 18.05.2005
Сообщений: 1,981
Провел на форуме:
1941233

Репутация: 2726


По умолчанию

Код:
function searchgoogle( $search, $start )
{
	GLOBAL $google_host, $gfrom, $gto;

	$start = intval( $start );
	$ret = "";

	$u = "http://$google_host/search?q=".urlencode( $search )."&num=100&start=$start";
	$f = @fopen( $u, "r" );
	if (!$f)
	{
		// Google connection failed
		return 0;
	}

	$data = "";
	while (!feof( $f ))
		$data .= fread( $f, 1024 );
	fclose( $f );

	preg_match_all( "/<p class=g><a class=l href=\"(.*)\">/U", $data, $links, PREG_SET_ORDER );
	foreach( $links as $l )
		$ret .= $l[1]."\r\n";

	if (!preg_match_all( "/ <b>([0-9]*)<\/b> - <b>([0-9]*)<\/b> /U", $data, $fromto, PREG_SET_ORDER ))
	{
		sleep( 2 );
		return 0;
	}
	$results_from = intval( $fromto[0][1] );
	$results_to = intval( $fromto[0][2] );
	if ($results_from && $results_to && ($results_to - $results_from == 99))
	{
		if ($gfrom && $gto)
			sleep( rand( $gfrom, $gto ) );
		else
			sleep( 5, 15 );
		$ret .= searchgoogle( $search, $results_from+99 );
	}
	return $ret;
}

print searchgoogle( "skachat berkovu porno dom2" );
 
Ответить с цитированием