@microlink/google 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +0 -0
- package/package.json +43 -22
- package/src/css/style.css +1152 -0
- package/src/index.d.ts +19 -0
- package/src/index.js +23 -16
- package/src/js/main.js +397 -0
- package/README.md +0 -280
package/README.md
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
# @microlink/google
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
[](https://coveralls.io/github/microlinkhq/microlink-google)
|
|
5
|
-
[](https://www.npmjs.org/package/@microlink/google)
|
|
6
|
-
|
|
7
|
-
> Turn Google into a structured API.
|
|
8
|
-
> Query Search, News, Images, Videos, Places, Maps, Shopping, Scholar, Patents, and Autocomplete — and get normalized data ready for code.
|
|
9
|
-
|
|
10
|
-
## Highlights
|
|
11
|
-
|
|
12
|
-
- **10 Google verticals in one API**
|
|
13
|
-
Search, News, Images, Videos, Places, Maps, Shopping, Scholar, Patents, and Autocomplete.
|
|
14
|
-
|
|
15
|
-
- **Normalized data**
|
|
16
|
-
Dates → ISO 8601
|
|
17
|
-
Prices → `{ symbol, amount }`
|
|
18
|
-
Ratings → `{ score, total, reviews }`
|
|
19
|
-
|
|
20
|
-
- **Lazy HTML fetching**
|
|
21
|
-
Any result with a `url` exposes `.html()` to fetch the page HTML on demand.
|
|
22
|
-
|
|
23
|
-
- **Built-in pagination**
|
|
24
|
-
Just call `.next()` to fetch the next page.
|
|
25
|
-
|
|
26
|
-
- **Fast**
|
|
27
|
-
~1 second response time per request with full parallelization support.
|
|
28
|
-
|
|
29
|
-
- **Full TypeScript support**
|
|
30
|
-
Type-specific inference out of the box.
|
|
31
|
-
|
|
32
|
-
## Install
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npm install @microlink/google
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Quick start
|
|
39
|
-
|
|
40
|
-
### Your first query
|
|
41
|
-
|
|
42
|
-
Initialize `@microlink/google`. The only prerequisite is a [Microlink API key](https://microlink.io/#pricing):
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
const google = require('@microlink/google')({
|
|
46
|
-
apiKey: process.env.MICROLINK_API_KEY
|
|
47
|
-
})
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Make your first query:
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
const page = await google('Lotus Elise S2')
|
|
54
|
-
|
|
55
|
-
console.log(page.results)
|
|
56
|
-
// [
|
|
57
|
-
// {
|
|
58
|
-
// title: 'Lotus Elise - Wikipedia',
|
|
59
|
-
// url: 'https://en.wikipedia.org/wiki/Lotus_Elise',
|
|
60
|
-
// description: 'The Lotus Elise is a two-seat, rear-wheel-drive...'
|
|
61
|
-
// }
|
|
62
|
-
// ]
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Use [Google search operators](https://ahrefs.com/blog/google-advanced-search-operators/) to refine queries:
|
|
66
|
-
|
|
67
|
-
```js
|
|
68
|
-
const page = await google('Lotus Elise S2 filetype:pdf')
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Localize results using `location` or filter by time with `period`:
|
|
72
|
-
|
|
73
|
-
```js
|
|
74
|
-
await google('recetas de pasta', {
|
|
75
|
-
location: 'es',
|
|
76
|
-
period: 'week'
|
|
77
|
-
})
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### Get HTML markup
|
|
81
|
-
|
|
82
|
-
Any result containing a `url` exposes a lazy `.html()` method:
|
|
83
|
-
|
|
84
|
-
```js
|
|
85
|
-
const { results } = await google('node.js frameworks')
|
|
86
|
-
|
|
87
|
-
for (const result of results) {
|
|
88
|
-
const html = await result.html()
|
|
89
|
-
console.log(html)
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Pagination
|
|
94
|
-
|
|
95
|
-
Pages chain naturally:
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
const page1 = await google('node.js frameworks')
|
|
99
|
-
const page2 = await page1.next()
|
|
100
|
-
const page3 = await page2.next()
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
You can also iterate:
|
|
104
|
-
|
|
105
|
-
```js
|
|
106
|
-
let page = await google('node.js frameworks')
|
|
107
|
-
|
|
108
|
-
while (page) {
|
|
109
|
-
for (const result of page.results) {
|
|
110
|
-
console.log(result.title)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
page = await page.next()
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
# Google products
|
|
118
|
-
|
|
119
|
-
| Type | Product | Example |
|
|
120
|
-
| -------------- | ------------------- | ----------------------------------------------------------- |
|
|
121
|
-
| `search` | Google Search | `google('Lotus Elise S2')` |
|
|
122
|
-
| `news` | Google News | `google('artificial intelligence', { type: 'news' })` |
|
|
123
|
-
| `images` | Google Images | `google('northern lights', { type: 'images' })` |
|
|
124
|
-
| `videos` | Google Videos | `google('cooking tutorial', { type: 'videos' })` |
|
|
125
|
-
| `places` | Google Places | `google('coffee shops denver', { type: 'places' })` |
|
|
126
|
-
| `maps` | Google Maps | `google('apple store new york', { type: 'maps' })` |
|
|
127
|
-
| `shopping` | Google Shopping | `google('macbook pro', { type: 'shopping' })` |
|
|
128
|
-
| `scholar` | Google Scholar | `google('transformer architecture', { type: 'scholar' })` |
|
|
129
|
-
| `patents` | Google Patents | `google('touchscreen gestures apple', { type: 'patents' })` |
|
|
130
|
-
| `autocomplete` | Google Autocomplete | `google('how to', { type: 'autocomplete' })` |
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## Google Search
|
|
135
|
-
|
|
136
|
-
Web results with knowledge graph, related questions, and related searches.
|
|
137
|
-
|
|
138
|
-
```js
|
|
139
|
-
const page = await google('Lotus Elise S2')
|
|
140
|
-
|
|
141
|
-
page.results[0]
|
|
142
|
-
|
|
143
|
-
page.knowledgeGraph
|
|
144
|
-
page.peopleAlsoAsk
|
|
145
|
-
page.relatedSearches
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## Google News
|
|
149
|
-
|
|
150
|
-
Recent articles with publisher, date, and thumbnail.
|
|
151
|
-
|
|
152
|
-
```js
|
|
153
|
-
const page = await google('artificial intelligence', { type: 'news' })
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## Google Images
|
|
157
|
-
|
|
158
|
-
Full-resolution image URLs with dimensions.
|
|
159
|
-
|
|
160
|
-
```js
|
|
161
|
-
const page = await google('northern lights', { type: 'images' })
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Google Videos
|
|
165
|
-
|
|
166
|
-
Video metadata with duration in milliseconds.
|
|
167
|
-
|
|
168
|
-
```js
|
|
169
|
-
const page = await google('cooking tutorial', { type: 'videos' })
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## Google Places
|
|
173
|
-
|
|
174
|
-
Local business listings with coordinates and contact info.
|
|
175
|
-
|
|
176
|
-
```js
|
|
177
|
-
const page = await google('coffee shops denver', { type: 'places' })
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## Google Maps
|
|
181
|
-
|
|
182
|
-
Detailed place data with ratings, hours, and pricing.
|
|
183
|
-
|
|
184
|
-
```js
|
|
185
|
-
const page = await google('apple store new york', { type: 'maps' })
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
## Google Shopping
|
|
189
|
-
|
|
190
|
-
Product listings with parsed prices and structured ratings.
|
|
191
|
-
|
|
192
|
-
```js
|
|
193
|
-
const page = await google('macbook pro', { type: 'shopping' })
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## Google Scholar
|
|
197
|
-
|
|
198
|
-
Academic papers with citation counts and PDF links.
|
|
199
|
-
|
|
200
|
-
```js
|
|
201
|
-
const page = await google('transformer architecture', { type: 'scholar' })
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## Google Patents
|
|
205
|
-
|
|
206
|
-
Patent filings with ISO 8601 dates and metadata.
|
|
207
|
-
|
|
208
|
-
```js
|
|
209
|
-
const page = await google('touchscreen gestures apple', { type: 'patents' })
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## Google Autocomplete
|
|
213
|
-
|
|
214
|
-
Search suggestions as you type.
|
|
215
|
-
|
|
216
|
-
```js
|
|
217
|
-
const page = await google('how to', { type: 'autocomplete' })
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
# API
|
|
221
|
-
|
|
222
|
-
## google(query, options?)
|
|
223
|
-
|
|
224
|
-
### query
|
|
225
|
-
|
|
226
|
-
**Required**
|
|
227
|
-
Type: `string`
|
|
228
|
-
|
|
229
|
-
The search query. Supports [Google search operators](https://support.google.com/websearch/answer/2466433).
|
|
230
|
-
|
|
231
|
-
```js
|
|
232
|
-
await google('annual report filetype:pdf')
|
|
233
|
-
await google('security updates site:github.com')
|
|
234
|
-
await google('"machine learning" site:arxiv.org')
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### options
|
|
238
|
-
|
|
239
|
-
#### type
|
|
240
|
-
|
|
241
|
-
Type: `string`<br>
|
|
242
|
-
Default: `'search'`<br>
|
|
243
|
-
Values: `'search'` | `'news'` | `'images'` | `'videos'` | `'places'` | `'maps'` | `'shopping'` | `'scholar'` | `'patents'` | `'autocomplete'`
|
|
244
|
-
|
|
245
|
-
Selects which Google product to query.
|
|
246
|
-
|
|
247
|
-
```js
|
|
248
|
-
await google('artificial intelligence', { type: 'news' })
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
#### location
|
|
252
|
-
|
|
253
|
-
Type: `string`<br>
|
|
254
|
-
Default: `'us'`<br>
|
|
255
|
-
Values: [`Location`](https://github.com/microlinkhq/google/blob/master/src/index.d.ts#L28)
|
|
256
|
-
|
|
257
|
-
Controls result geolocation using a country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). This influences ranking, language, and local intent.
|
|
258
|
-
|
|
259
|
-
```js
|
|
260
|
-
await google('recetas de pasta', { location: 'es' })
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
#### period
|
|
264
|
-
|
|
265
|
-
Type: `string`<br>
|
|
266
|
-
Default: `undefined`<br>
|
|
267
|
-
Values: `hour` | `day` | `week` | `month` | `year`
|
|
268
|
-
|
|
269
|
-
Limits results to a recent time window. Useful for news monitoring and freshness-sensitive queries.
|
|
270
|
-
|
|
271
|
-
```js
|
|
272
|
-
await google('tech news', { period: 'week' })
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
## License
|
|
276
|
-
|
|
277
|
-
**@microlink/google** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/google/blob/master/LICENSE.md) License.<br>
|
|
278
|
-
Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/microlinkhq/google/contributors).
|
|
279
|
-
|
|
280
|
-
> [microlink.io](https://microlink.io) · GitHub [microlinkhq](https://github.com/microlinkhq) · X [@microlinkhq](https://x.com/microlinkhq)
|