• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

vadimdemedes/google-images: Search for images using Google Images

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

vadimdemedes/google-images

开源软件地址(OpenSource Url):

https://github.com/vadimdemedes/google-images

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

google-images Build Status

Search images using Google Custom Search Engine API.

Installation

$ npm install --save google-images

Usage

Note: You'll need to set up your own Google Custom Search Engine to execute queries.

const GoogleImages = require('google-images');

const client = new GoogleImages('CSE ID', 'API KEY');

client.search('Steve Angello')
	.then(images => {
		/*
		[{
			"url": "http://steveangello.com/boss.jpg",
			"type": "image/jpeg",
			"width": 1024,
			"height": 768,
			"size": 102451,
			"thumbnail": {
				"url": "http://steveangello.com/thumbnail.jpg",
				"width": 512,
				"height": 512
			}
		}]
		 */
	});

// paginate results
client.search('Steve Angello', {page: 2});

// search for certain size
client.search('Steve Angello', {size: 'large'});

API

Please see Google's API documentation for details on the option and response properties and their possible values. Note that the option names used here may differ slightly (e.g. no img prefix).

Client(engineId, apiKey)

engineId

Type: string

The identifier for a Custom Search Engine to use.

apiKey

Type: string

The credentials for accessing Google's API.

Instance

.search(query, option)

Perform an image search for query.

query

Type: string

The search terms to use for finding images. Identical to those you would use in a web search.

option

Type: object

page

Type: number
Default: 1

The range of results to return. Useful because often results cannot be returned in a single response. Note that it is a one-based unsigned integer. E.g. page 1 has the first 10 results, page 2 has the next set of 10, etc.

size

Type: string

The size of images to search. E.g. medium or xxlarge.

type

Type: string

The category of images to search. E.g. face or photo.

dominantColor

Type: string

The dominant color to search for. E.g. yellow or purple.

colorType

Type: string

The category of color spectrums to search. E.g. gray or color.

safe

Type: string

The heuristic level to use for filtering out explicit content using SafeSearch. E.g. off or high.

Set up Google Custom Search Engine

Google deprecated their public Google Images API, so to search for images you need to sign up for Google Custom Search Engine. Here are the steps you need to do:

1. Create a Google Custom Search Engine

You can do this here: https://cse.google.com/cse.

Do not specify any sites to search but instead use the "Restrict Pages using Schema.org Types" under the "Advanced options". For the most inclusive set, use the Schema: Thing. Make a note of the CSE ID.

2. Enable Image Search

In your search engine settings, enable "Image search":

3. Set up a Google Custom Search Engine API

Register a new app and enable Google Custom Search Engine API here: Google Developers Console. Make a note of the API key.

License

MIT © Vadim Demedes




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
cloudyr/googleComputeEngineR: An R interface to the Google Cloud Compute API, fo ...发布时间:2022-06-11
下一篇:
google/google-input-tools发布时间:2022-06-11
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap