Created
December 5, 2015 02:08
-
-
Save williamho/9b67275d30cd79f2280c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # In Gemfile: | |
| # gem 'google-api-client', '0.9.pre3' | |
| require 'google/apis/customsearch_v1' | |
| Customsearch = Google::Apis::CustomsearchV1 | |
| search = Customsearch::CustomsearchService.new | |
| # https://cse.google.com/cse/all | |
| # Click name of CSE to edit | |
| # Image search => On | |
| # Sites to search => Search the entire web but emphasize included sites | |
| search.key = 'insert here' | |
| # Details: Search Engine ID | |
| cx = 'insert here' | |
| search_term = 'snow' | |
| results = search.list_cses( | |
| search_term, | |
| cx: cx, | |
| search_type: 'image' | |
| ) | |
| puts results.items.sample.link |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment