1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Google trends api

Discussion in 'Google API' started by look4guna, Dec 18, 2010.

  1. #1
    Hi friends,

    can anybody tell me how to get google api to get googletrends results....
     
    look4guna, Dec 18, 2010 IP
  2. Oceanus

    Oceanus Member

    Messages:
    903
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    There are third party tools available.
     
    Oceanus, Feb 10, 2011 IP
  3. look4guna

    look4guna Active Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    Hi Oceanus,
    Thanks for your reply, but these two functions will provide hourly trends.

    function grabTrends()
    {
    //for USA ->"http://www.google.com/trends/hottrends/atom/hourly"
    $arr = $this->curlGrab("http://www.google.co.in/trends/hottrends/atom/hourly");
    //patterns to find keys and links
    $ptnkeys = '|&sa=X">(.*?)</a>|';
    $ptnlinks='/<a href=\"([^\"]*)\">(.*)<\/a>/iU';

    preg_match_all( $ptnkeys, $arr['page'], $keys );
    preg_match_all( $ptnlinks, $arr['page'], $links );
    $keys=$keys[1];
    $links=$links[1];
    for($i=0;$i<count($keys);$i++)
    {
    $contents[count($contents)]=array($keys[$i],$links[$i]);
    }
    return $contents;

    }

    function curlGrab( $url)
    { //---- functio to get data from a website--/
    $ch = curl_init( $url );
    curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_COOKIEJAR, 'cookies.txt' );
    curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01;Windows NT 5.0)" );

    $arr[ 'page' ] = curl_exec( $ch );
    return $arr;
    }


    But Now i need to get full trends for previous day, i couln't find any feed to provide this. Do you know???
     
    look4guna, Feb 10, 2011 IP
  4. stannisthem

    stannisthem Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,

    There is a php library here to read google trends and you can define the time range. For example:

    $gs=newGSession($guser, $gpass);
    $gs->authenticate();
    $gt=new GTrends($gs,'en');
    $gt->addTerm('something1')->setTime('2017-4-18 2017-04-19');
    $gt->getGraph('csv'));
     
    stannisthem, Apr 19, 2017 IP