Google Trends Scraper

imfcuk

Make Money Online
Very Active Members
Joined
Sep 15, 2009
Messages
1,382
Reaction score
10
Points
0
Google Trends Scrapper using Atom Feeds

PHP:
function get_trends() { 
    $url='http://www.google.com/trends/hottrends/atom/hourly'; 
    $feed = @simplexml_load_file($url,'SimpleXMLElement', LIBXML_NOCDATA); 
    $html=  $feed->entry->content; 
    preg_match_all('#([^<]+)#',$html[0],$match); 
    return $match[2]; 
    }
<code style="white-space: nowrap;"><code>


</code></code>Requirements:
PHP 5.1.0 and Libxml 2.6.0+
 

Ricardo

Make Money Online
Joined
Sep 24, 2009
Messages
18
Reaction score
0
Points
0
Age
32
thanks bro i was going to code this myself but since you already did it.. :)
 

TREVERS

Make Money Online
Joined
Sep 15, 2010
Messages
64
Reaction score
0
Points
6
Age
35
I don't want to write a long sales letter to hype you up into buying this product
 

littlepony

Make Money Online
Very Active Members
Joined
Jul 5, 2010
Messages
106
Reaction score
0
Points
0
how to use it ? please help, i am not familiar with codes too.
 

soma56

Make Money Online
Joined
Sep 24, 2009
Messages
293
Reaction score
4
Points
17
Website
socialemailextractor.com
This is a function that is used in a programming language called php. You'll either need XAMPP or WAMP to run the script locally (on your own computer). The complexities of installing wither of these goes way beyond this post.

If you have a hosting account then chances are you have php installed. It's quite popular. Copy the code and paste it in notepad. Before you save it you have to establish the code as being php by wrapping an opening php tag "<?PHP" and a closing php tag "?>" around the function. So essentially it will look like this:

Code:
<?PHP 

function get_trends() { 
    $url='http://www.google.com/trends/hottrends/atom/hourly'; 
    $feed = @simplexml_load_file($url,'SimpleXMLElement', LIBXML_NOCDATA); 
    $html=  $feed->entry->content; 
    preg_match_all('#([^<]+)#',$html[0],$match); 
    return $match[2]; 
    } 

?>
Saving and running this code won't do anything because you haven't 'called the function'. Think of the script so far like this: It's a super powerful light, all hooked up with wiring and everything - but you haven't flicked the switch, or in PHP, called a function.

Try this,

Code:
<?PHP 

function get_url_contents($url){
        $crl = curl_init();
        $timeout = 15;
        curl_setopt ($crl, CURLOPT_URL,$url);
        curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
        $ret = curl_exec($crl);
        echo strip_tags(nl2br($ret), '<br>');
        curl_close($crl);
}

get_url_contents("http://www.google.com/trends/hottrends/atom/hourly");

?>
Not to rain on imfcuks parade, but I whipped this together. It strips the html and returns a plain page with the latest Google trends.

Copy and save it in notepage as trends.php
Upload it to you server
Go to www.yoursite.com/trends.php

I would just assume to go to the actual trends page myself unless you wanted to further pass the data into another program for some other purpose(s).
 

wcd

Make Money Online
Very Active Members
Joined
Nov 25, 2010
Messages
78
Reaction score
0
Points
6
Age
26
for those too lazy to try
here is a ready made deployment of above code
enjoy

Code:
http://www.dashingwallpapers.com/extra/trends.php
 

badar

Make Money Online
Joined
Mar 20, 2010
Messages
16
Reaction score
0
Points
1
Age
35
wcd, thanks for the share, this tool is actually looking good to me.
 

SUV

Make Money Online
Joined
Jun 22, 2010
Messages
50
Reaction score
0
Points
0
Cool sharing..thanks a lot for being doing all the hard work
 

gorico

Make Money Online
Joined
Nov 12, 2010
Messages
41
Reaction score
0
Points
0
It is very interesting and useful code.Thank you for sharing.