Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google_cse

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google_cse

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Google Custom Search

This project is a Ruby API to Google's Custom Search Engine (http://www.google.com/cse). This plugin is rewrite plugin from Alex Reisner (http://github.com/alexreisner/google_custom_search.git), because the old plugin not working.

== 1. Install

Install either as a Rails plugin:

rails plugin install git://github.com/vodafon/google_cse.git

or as a gem:

add to Gemfile:

gem "google_cse"

at command prompt:

bundle install

or as a standalone gem (outside of Rails):

sudo gem install google_cse

== 2. Configure

You must define a constant in your application called CX_GOOGLE_CSE. For example, if you're using Rails, create a file config/initializers/google_cse.rb:

CX_GOOGLE_CSE = "..."

You can find the CX value for your custom search engine via the search control panel on Google's site (click the "Get code" link and you'll see a hidden "cx" field in the sample HTML form).

== 3. Use

To perform a search:

results = GoogleCustomSearch.search("Hank Aaron", 0)

The second parameter is a start parameter for search query. 0 - first page (1-10 result), 10 - second page, etc.

The +results+ variable is now a GoogleCustomSearch::ResultSet object:

results.pages # array of pages data results.results # array of result objects

Iterate through the results:

results.results.each do |result| result.title # result title result.url # result URL result.description # excerpt, with terms highlighted end

Copyright (c) 2010 Igor Vodafon, released under the MIT license

FAQs

Package last updated on 14 Sep 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc