Web scraping
Inviato: 22/05/2013, 17:31
Ciao a tutti!! Volevo effettuare un web scraping in Pinterest, mi servirebbe ricavare i nomi dei follower di alcune persone...ho provato a scrivere un po di codice ma mi da errori.....potete darmi una mano?
<?php
header('content-type: text/plain');
$base_url = 'http://pinterest.com/';
$contents = file_get_contents('http://pinterest.com/kathcourt/followers/');
$contents = preg_replace('/\s{1,}/',' ', $contents);
$records = preg_split('/<h3 class="username/',$contents);
$r = Array();
for ($i=1; $i < count($records); $i++) {
$tmp= $records[$i];
preg_match('/>.*?">(.*?)</', $tmp, $match_username);
$r[] = Array('name' => $match_username[1]);
}
print_r($r);
?>
<?php
header('content-type: text/plain');
$base_url = 'http://pinterest.com/';
$contents = file_get_contents('http://pinterest.com/kathcourt/followers/');
$contents = preg_replace('/\s{1,}/',' ', $contents);
$records = preg_split('/<h3 class="username/',$contents);
$r = Array();
for ($i=1; $i < count($records); $i++) {
$tmp= $records[$i];
preg_match('/>.*?">(.*?)</', $tmp, $match_username);
$r[] = Array('name' => $match_username[1]);
}
print_r($r);
?>