目录
1.建立Custom Search Engine
得到search engine ID,必须先建立 Custom Search Engine。
我们连到Custom Search Engine control panel 建立Search Engine。
https://cse.google.com/cse/all
取得Search Engine ID , 把值复制下来
2.到API key网站 获取 api key
https://developers.google.com/custom-search/v1/overview
取得API key
3.测试 api key 搜索
有了search engine ID & API key,我们将可采用以下网址搜寻Google 上丰富资料。
网址至少要包含以下三个参数:
key: API key
cx: search engine ID
q: 搜寻的文字
接下来我们就可以在浏览器输入要查询的资料,之后就可以在App中放入查询的API
get 搜索 实例:
其中 INSERT_YOUR_API_KEY 换成自己 api key
4.搜索参数列表
原文链接:https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list
Parameters | |
---|---|
c2coff |
Enables or disables Simplified and Traditional Chinese Search. The default value for this parameter is 0 (zero), meaning that the feature is enabled. Supported values are:
|
cr |
Restricts search results to documents originating in a particular country. You may use Boolean operators in the cr parameter's value. Google Search determines the country of a document by analyzing:
See the Country Parameter Values page for a list of valid values for this parameter. |
cx |
The Programmable Search Engine ID to use for this request. |
dateRestrict |
Restricts results to URLs based on date. Supported values include:
|
exactTerms |
Identifies a phrase that all documents in the search results must contain. |
excludeTerms |
Identifies a word or phrase that should not appear in any documents in the search results. |
fileType |
Restricts results to files of a specified extension. A list of file types indexable by Google can be found in Search Console Help Center. |
filter |
Controls turning on or off the duplicate content filter.
Acceptable values are:
|
gl |
Geolocation of end user.
|
googlehost |
Deprecated. Use the The local Google domain (for example, google.com, google.de, or google.fr) to use to perform the search. |
highRange |
Specifies the ending value for a search range.
|
hl |
Sets the user interface language.
|
hq |
Appends the specified query terms to the query, as if they were combined with a logical AND operator. |
imgColorType |
Returns black and white, grayscale, transparent, or color images. Acceptable values are:
|
imgDominantColor |
Returns images of a specific dominant color. Acceptable values are:
|
imgSize |
Returns images of a specified size. Acceptable values are:
|
imgType |
Returns images of a type. Acceptable values are:
|
linkSite |
Specifies that all search results should contain a link to a particular URL. |
lowRange |
Specifies the starting value for a search range. Use |
lr |
Restricts the search to documents written in a particular language (e.g., Acceptable values are:
|
num |
Number of search results to return.
|
orTerms |
Provides additional search terms to check for in a document, where each document in the search results must contain at least one of the additional search terms. |
q |
Query |
relatedSite |
Specifies that all search results should be pages that are related to the specified URL. |
rights |
Filters based on licensing. Supported values include: |
safe |
Search safety level. Acceptable values are:
|
searchType |
Specifies the search type: Acceptable values are:
|
siteSearch |
Specifies a given site which should always be included or excluded from results (see |
siteSearchFilter |
Controls whether to include or exclude results from the site named in the Acceptable values are:
|
sort |
The sort expression to apply to the results. The sort parameter specifies that the results be sorted according to the specified expression i.e. sort by date. Example: sort=date. |
start |
The index of the first result to return. The default number of results per page is 10, so |