This is a basic php script with CURL and XML parsing to get latest Google Trends title. It will provide how to build the script. The script is using alot marketers, researchers, website owners, and SEO experts until now. Here we go,
You can change "p1" on line 13 with other code number. You can check it all at www.google.com/trends/explore. Basically, "p1" is default for US country. Or you can view the result at my website http://allpreview.net (at homepage). Its support until 46 google trends by country.
PHP:
<?php
function get_url($url){
$agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$result = curl_exec($ch);
return $result;
}
$url = get_url('http://www.google.com/trends/hottrends/atom/feed?pn=p1');
$trends = new SimpleXmlElement($url);
$data = $trends->channel->item;
for($j=0; $j < count($data); $j++) {
echo $data[$j]->title."<br>";
}
?>
You can change "p1" on line 13 with other code number. You can check it all at www.google.com/trends/explore. Basically, "p1" is default for US country. Or you can view the result at my website http://allpreview.net (at homepage). Its support until 46 google trends by country.