Giter Site home page Giter Site logo

googletrend's Introduction

GoogleTrend

Google Trend API codeigniter php

This is a basic libary enable you to read/save google trends keywords as a JSON once a day. If JSON appear, read it. If not, curl the keyword and save as a JSON for next request. This library is used with the curl.

Package CodeIgniter / PHP
Subpackage Libraries
Author kelvin Kwong Ho
Version 0.1
Date 9/1/2013

What to solve

For some moments, my site needs a content or keyword for dynamic run or request. Like the site of http://zonmine.com, call google trend once a day to gather the hot keyword in shopping (for 30 days and 7 days ). Then it uses the Gtrend keyword to search products in Amazon. The content will appear updating daily and easily go up to 2000-5000 products in few days.

Features

Get the google trend keywod and save as a JSON

Requirements

  1. PHP 5.1+ with curl which I used a Curl library ( https://github.com/philsturgeon/codeigniter-curl ) .
  2. CodeIgniter

Example

default call

$response = $this->create_trend_keyword( );

//return json ["ipod","tv","camera","xbox","sony","speakers","nikon","xbox 360","headphones","ipod touch"]

Instruction

  1. Put the Gtrend.php under codeigniter "application/libraries" and make sure you have the Curl.php or $this->curl funtion

  2. Loading the libraries by either one of the following way:
    a. Autoload 'config/Autoload.php' add a param in $autoload['libraries'] = array('Curl', 'Gtrend');
    b.

    function __construct() {
    parent::__construct();
    $this->load->library('Gtrend');
    }

    c.
    $this->load->library('Gtrend'); 

  3. setup the JSON file data path : $config['data_base_path'] = 'www/data/';

  4. Call the library as follow :

 $result = $this->create_trend_keyword( ); //default is cat "0-18-78" => Shopping > Consumer Electronics, type TOP  
 $result = $this->create_trend_keyword( $category, $type );
  1. The keyword JSON is now stored as {data_base_path}/{Ymd_type_cat_}.json
    e.g. 20130901_TOP_0-18-78_.json
    Content :
["ipod","tv","camera","xbox","sony","speakers","nikon","xbox 360","headphones","ipod touch"]  

Download

https://github.com/kelvin2go/GoogleTrend/

Example of usage on website

http://zonmine.com

Remarks:

The data is from
http://www.google.com/trends/fetchComponent

http://www.google.com/trends/fetchComponent?hl=en-US&cat=0-18-78&geo=US&date=today+1-m&gprop=froogle&cmpt=q&content=1&cid=TOP_QUERIES_0_0&export=3

You will have chance to reach your limit for curling google trends.

If you have any questions or found any bugs, please message or pull request me.

googletrend's People

Contributors

kelvin2go avatar

Watchers

Benjamin avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.