/
cse.clj
59 lines (51 loc) · 2.2 KB
/
cse.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(ns happygapi.customsearch.cse
"CustomSearch API: cse.
Searches over a website or collection of websites
See: https://developers.google.com/custom-search/v1/using_restapi/reference/rest/v1/cse"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn list$
"https://developers.google.com/custom-search/v1/using_restapi/reference/rest/v1/cse/list
Required parameters: q
Optional parameters: lr, num, excludeTerms, relatedSite, fileType, searchType, siteSearch, imgSize, orTerms, start, cr, hq, filter, imgColorType, exactTerms, hl, rights, imgDominantColor, imgType, cx, gl, dateRestrict, googlehost, c2coff, safe, siteSearchFilter, lowRange, sort, linkSite, highRange
Returns metadata about the search performed, metadata about the custom search engine used for the search, and the search results."
{:scopes nil}
[auth parameters]
{:pre [(util/has-keys? parameters #{:q})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/customsearch/"
"v1"
#{:q}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn siterestrict-list$
"https://developers.google.com/custom-search/v1/using_restapi/reference/rest/v1/cse/siterestrict/list
Required parameters: q
Optional parameters: lr, num, excludeTerms, relatedSite, fileType, searchType, siteSearch, imgSize, orTerms, start, cr, hq, filter, imgColorType, exactTerms, hl, rights, imgDominantColor, imgType, cx, gl, dateRestrict, googlehost, c2coff, safe, siteSearchFilter, lowRange, sort, linkSite, highRange
Returns metadata about the search performed, metadata about the custom search engine used for the search, and the search results. Uses a small set of url patterns."
{:scopes nil}
[auth parameters]
{:pre [(util/has-keys? parameters #{:q})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/customsearch/"
"v1/siterestrict"
#{:q}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))