Simple Tool to Collect Pinterest Pins/Boards

I created a simple tool that collects pinterest pins and boards just by typing in a pinterest user name. It uses a modified API I found at http://pinterestapi.co.uk. The drawback to…

I created a simple tool that collects pinterest pins and boards just by typing in a pinterest user name. It uses a modified API I found at http://pinterestapi.co.uk. The drawback to this API is that it limits to 50 records. Until pinterest gets their act together and provides a full API, the best we can do is scrape the site. I also have some PHP code that can be used to scrape for boards.

http://www.slingspace.com/socialtools/pinterest/index.php?user=

<?php
$target_url = “http://www.pinterest.com/hersheycompany”;
$userAgent = ‘ScraperBot’;
$qw = curl_init();
curl_setopt($qw, CURLOPT_USERAGENT, $userAgent);
curl_setopt($qw, CURLOPT_URL,$target_url);
curl_setopt($qw, CURLOPT_FAILONERROR, true);
curl_setopt($qw, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($qw, CURLOPT_AUTOREFERER, true);
curl_setopt($qw, CURLOPT_RETURNTRANSFER,true);
curl_setopt($qw, CURLOPT_TIMEOUT, 20);

$html= curl_exec($qw);
if (!$html)
{
echo “ERROR NUMBER: “.curl_errno($ch);
echo “ERROR: “.curl_error($ch);
exit;
}

$dom = new DOMDocument();
@$dom->loadHTML($html);

$xpath = new DOMXPath($dom);
$href = $xpath->evaluate(“/html/body//h3/a”);

for ($i = 0; $i < $href->length; $i++) {
$data = $href->item($i);
$url = $data->getAttribute(‘href’);
echo $url . “<br>”;
}
?>