
06.04.2009, 19:35
|
|
Новичок
Регистрация: 07.07.2008
Сообщений: 6
С нами:
9391835
Репутация:
10
|
|
Парсит ссылки с гугла по кейворду
PHP код:
<?php
/*
|
| www.google.ru parser
| C0d3d by Exgibichi
| 27/07/08
|
*/
set_time_limit(0);
$n = 20; // number of pages
$keyword = 'keyword'; //keyword for parse
function googlelinkparse($keyword,$n) {
$keyword = str_replace(' ','+',$keyword);
$url = 'http://www.google.ru/search?q='.$keyword.'&num=100&filter=0&start='.$n.'0';
$file = file_get_contents($url) or die('Could not access file');
$exp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
if (preg_match_all("/$exp/siU", $file, $matches, PREG_SET_ORDER)) {
$c = count($matches);
for ($i=0; $i<$c; $i++) {
if (strstr($matches[$i][2],'http://') && !strstr($matches[$i][2],'google') && !strstr($matches[$i][2],'search?q=cache') && !strstr($matches[$i][2],'youtube') && !strstr($matches[$i][2],'/aclk?sa')) {
$links[] = $matches[$i][2];
}
}
} return $links;
}
for ($i=0; $i<$n; $i++) {
$link = googlelinkparse($keyword,$i);
$c = count($link);
for ($j=0; $j<$c; $j++) {
$f = fopen('links.txt','a+'); fputs($f,$link[$j]."\r\n"); fclose($f);
}
sleep(10);
}
?>
|
|
|