@isdk/web-searcher 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/README.cn.md +274 -0
- package/README.md +274 -0
- package/dist/index.d.mts +321 -0
- package/dist/index.d.ts +321 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/docs/README.md +278 -0
- package/docs/classes/GoogleSearcher.md +695 -0
- package/docs/classes/WebSearcher.md +661 -0
- package/docs/globals.md +26 -0
- package/docs/interfaces/CustomTimeRange.md +29 -0
- package/docs/interfaces/PaginationConfig.md +86 -0
- package/docs/interfaces/SearchContext.md +41 -0
- package/docs/interfaces/SearchOptions.md +105 -0
- package/docs/interfaces/StandardSearchResult.md +58 -0
- package/docs/type-aliases/SafeSearchLevel.md +11 -0
- package/docs/type-aliases/SearchCategory.md +11 -0
- package/docs/type-aliases/SearchTimeRange.md +11 -0
- package/docs/type-aliases/SearchTimeRangePreset.md +11 -0
- package/docs/type-aliases/SearcherConstructor.md +23 -0
- package/package.json +87 -0
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
[**@isdk/web-searcher**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/web-searcher](../globals.md) / WebSearcher
|
|
6
|
+
|
|
7
|
+
# Abstract Class: WebSearcher
|
|
8
|
+
|
|
9
|
+
Defined in: [web-searcher/src/searcher.ts:31](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L31)
|
|
10
|
+
|
|
11
|
+
The abstract base class for all search engines.
|
|
12
|
+
|
|
13
|
+
It extends `FetchSession`, meaning each `WebSearcher` instance is an active session
|
|
14
|
+
capable of maintaining state (e.g., cookies, local storage) across multiple search queries.
|
|
15
|
+
|
|
16
|
+
Developers should extend this class to create specific search engine implementations
|
|
17
|
+
(e.g., Google, Bing, DuckDuckGo).
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
class MySearcher extends WebSearcher {
|
|
23
|
+
get template() {
|
|
24
|
+
return { url: '...' };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
WebSearcher.register(MySearcher);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Extends
|
|
31
|
+
|
|
32
|
+
- `FetchSession`
|
|
33
|
+
|
|
34
|
+
## Extended by
|
|
35
|
+
|
|
36
|
+
- [`GoogleSearcher`](GoogleSearcher.md)
|
|
37
|
+
|
|
38
|
+
## Constructors
|
|
39
|
+
|
|
40
|
+
### Constructor
|
|
41
|
+
|
|
42
|
+
> **new WebSearcher**(`options?`): `WebSearcher`
|
|
43
|
+
|
|
44
|
+
Defined in: web-fetcher/dist/index.d.ts:2192
|
|
45
|
+
|
|
46
|
+
Creates a new FetchSession.
|
|
47
|
+
|
|
48
|
+
#### Parameters
|
|
49
|
+
|
|
50
|
+
##### options?
|
|
51
|
+
|
|
52
|
+
`FetcherOptions`
|
|
53
|
+
|
|
54
|
+
Configuration options for the fetcher.
|
|
55
|
+
|
|
56
|
+
#### Returns
|
|
57
|
+
|
|
58
|
+
`WebSearcher`
|
|
59
|
+
|
|
60
|
+
#### Inherited from
|
|
61
|
+
|
|
62
|
+
`FetchSession.constructor`
|
|
63
|
+
|
|
64
|
+
## Properties
|
|
65
|
+
|
|
66
|
+
### closed
|
|
67
|
+
|
|
68
|
+
> `protected` **closed**: `boolean`
|
|
69
|
+
|
|
70
|
+
Defined in: web-fetcher/dist/index.d.ts:2186
|
|
71
|
+
|
|
72
|
+
#### Inherited from
|
|
73
|
+
|
|
74
|
+
`FetchSession.closed`
|
|
75
|
+
|
|
76
|
+
***
|
|
77
|
+
|
|
78
|
+
### context
|
|
79
|
+
|
|
80
|
+
> `readonly` **context**: `FetchContext`
|
|
81
|
+
|
|
82
|
+
Defined in: web-fetcher/dist/index.d.ts:2185
|
|
83
|
+
|
|
84
|
+
The execution context for this session, containing configurations, event bus, and shared state.
|
|
85
|
+
|
|
86
|
+
#### Inherited from
|
|
87
|
+
|
|
88
|
+
`FetchSession.context`
|
|
89
|
+
|
|
90
|
+
***
|
|
91
|
+
|
|
92
|
+
### id
|
|
93
|
+
|
|
94
|
+
> `readonly` **id**: `string`
|
|
95
|
+
|
|
96
|
+
Defined in: web-fetcher/dist/index.d.ts:2181
|
|
97
|
+
|
|
98
|
+
Unique identifier for the session.
|
|
99
|
+
|
|
100
|
+
#### Inherited from
|
|
101
|
+
|
|
102
|
+
`FetchSession.id`
|
|
103
|
+
|
|
104
|
+
***
|
|
105
|
+
|
|
106
|
+
### options
|
|
107
|
+
|
|
108
|
+
> `protected` **options**: `FetcherOptions`
|
|
109
|
+
|
|
110
|
+
Defined in: web-fetcher/dist/index.d.ts:2177
|
|
111
|
+
|
|
112
|
+
#### Inherited from
|
|
113
|
+
|
|
114
|
+
`FetchSession.options`
|
|
115
|
+
|
|
116
|
+
***
|
|
117
|
+
|
|
118
|
+
### \_isFactory
|
|
119
|
+
|
|
120
|
+
> `static` **\_isFactory**: `boolean` = `false`
|
|
121
|
+
|
|
122
|
+
Defined in: [web-searcher/src/searcher.ts:33](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L33)
|
|
123
|
+
|
|
124
|
+
***
|
|
125
|
+
|
|
126
|
+
### alias?
|
|
127
|
+
|
|
128
|
+
> `static` `optional` **alias**: `string` \| `string`[]
|
|
129
|
+
|
|
130
|
+
Defined in: [web-searcher/src/searcher.ts:45](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L45)
|
|
131
|
+
|
|
132
|
+
Engine alias(es). Can be a single string or an array of strings.
|
|
133
|
+
Useful for registering shorthand names (e.g., 'g' for 'Google').
|
|
134
|
+
|
|
135
|
+
***
|
|
136
|
+
|
|
137
|
+
### createObject()
|
|
138
|
+
|
|
139
|
+
> `static` **createObject**: (`name`, ...`args`) => `WebSearcher`
|
|
140
|
+
|
|
141
|
+
Defined in: [web-searcher/src/searcher.ts:78](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L78)
|
|
142
|
+
|
|
143
|
+
Creates an instance of the registered search engine.
|
|
144
|
+
|
|
145
|
+
#### Parameters
|
|
146
|
+
|
|
147
|
+
##### name
|
|
148
|
+
|
|
149
|
+
`string`
|
|
150
|
+
|
|
151
|
+
The name of the engine.
|
|
152
|
+
|
|
153
|
+
##### args
|
|
154
|
+
|
|
155
|
+
...`any`[]
|
|
156
|
+
|
|
157
|
+
Arguments to pass to the constructor.
|
|
158
|
+
|
|
159
|
+
#### Returns
|
|
160
|
+
|
|
161
|
+
`WebSearcher`
|
|
162
|
+
|
|
163
|
+
An instance of the search engine.
|
|
164
|
+
|
|
165
|
+
***
|
|
166
|
+
|
|
167
|
+
### forEach()
|
|
168
|
+
|
|
169
|
+
> `static` **forEach**: (`cb`) => `void`
|
|
170
|
+
|
|
171
|
+
Defined in: [web-searcher/src/searcher.ts:85](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L85)
|
|
172
|
+
|
|
173
|
+
Iterates over all registered engines.
|
|
174
|
+
|
|
175
|
+
#### Parameters
|
|
176
|
+
|
|
177
|
+
##### cb
|
|
178
|
+
|
|
179
|
+
(`ctor`, `name`) => `void`
|
|
180
|
+
|
|
181
|
+
Callback function to invoke for each registered engine.
|
|
182
|
+
|
|
183
|
+
#### Returns
|
|
184
|
+
|
|
185
|
+
`void`
|
|
186
|
+
|
|
187
|
+
***
|
|
188
|
+
|
|
189
|
+
### get()
|
|
190
|
+
|
|
191
|
+
> `static` **get**: (`name`) => *typeof* `WebSearcher`
|
|
192
|
+
|
|
193
|
+
Defined in: [web-searcher/src/searcher.ts:69](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L69)
|
|
194
|
+
|
|
195
|
+
Retrieves a registered search engine class by name.
|
|
196
|
+
|
|
197
|
+
#### Parameters
|
|
198
|
+
|
|
199
|
+
##### name
|
|
200
|
+
|
|
201
|
+
`string`
|
|
202
|
+
|
|
203
|
+
The name of the engine (e.g., 'Google').
|
|
204
|
+
|
|
205
|
+
#### Returns
|
|
206
|
+
|
|
207
|
+
*typeof* `WebSearcher`
|
|
208
|
+
|
|
209
|
+
The search engine class constructor.
|
|
210
|
+
|
|
211
|
+
***
|
|
212
|
+
|
|
213
|
+
### name?
|
|
214
|
+
|
|
215
|
+
> `static` `optional` **name**: `string`
|
|
216
|
+
|
|
217
|
+
Defined in: [web-searcher/src/searcher.ts:40](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L40)
|
|
218
|
+
|
|
219
|
+
Custom engine name. If not provided, it is derived from the class name.
|
|
220
|
+
For example, `GoogleSearcher` becomes `Google`.
|
|
221
|
+
|
|
222
|
+
***
|
|
223
|
+
|
|
224
|
+
### register()
|
|
225
|
+
|
|
226
|
+
> `static` **register**: (`ctor`, `options?`) => `boolean`
|
|
227
|
+
|
|
228
|
+
Defined in: [web-searcher/src/searcher.ts:54](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L54)
|
|
229
|
+
|
|
230
|
+
Registers a search engine class.
|
|
231
|
+
|
|
232
|
+
#### Parameters
|
|
233
|
+
|
|
234
|
+
##### ctor
|
|
235
|
+
|
|
236
|
+
*typeof* `WebSearcher`
|
|
237
|
+
|
|
238
|
+
The search engine class to register.
|
|
239
|
+
|
|
240
|
+
##### options?
|
|
241
|
+
|
|
242
|
+
Registration options. If a string is provided, it is used as the registered name.
|
|
243
|
+
|
|
244
|
+
`string` | `IBaseFactoryOptions`
|
|
245
|
+
|
|
246
|
+
#### Returns
|
|
247
|
+
|
|
248
|
+
`boolean`
|
|
249
|
+
|
|
250
|
+
`true` if registration was successful.
|
|
251
|
+
|
|
252
|
+
***
|
|
253
|
+
|
|
254
|
+
### setAliases()
|
|
255
|
+
|
|
256
|
+
> `static` **setAliases**: (`ctor`, ...`aliases`) => `void`
|
|
257
|
+
|
|
258
|
+
Defined in: [web-searcher/src/searcher.ts:93](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L93)
|
|
259
|
+
|
|
260
|
+
Sets aliases for a registered engine.
|
|
261
|
+
|
|
262
|
+
#### Parameters
|
|
263
|
+
|
|
264
|
+
##### ctor
|
|
265
|
+
|
|
266
|
+
*typeof* `WebSearcher`
|
|
267
|
+
|
|
268
|
+
The search engine class.
|
|
269
|
+
|
|
270
|
+
##### aliases
|
|
271
|
+
|
|
272
|
+
...`string`[]
|
|
273
|
+
|
|
274
|
+
Aliases to add.
|
|
275
|
+
|
|
276
|
+
#### Returns
|
|
277
|
+
|
|
278
|
+
`void`
|
|
279
|
+
|
|
280
|
+
***
|
|
281
|
+
|
|
282
|
+
### unregister()
|
|
283
|
+
|
|
284
|
+
> `static` **unregister**: (`name?`) => `void`
|
|
285
|
+
|
|
286
|
+
Defined in: [web-searcher/src/searcher.ts:61](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L61)
|
|
287
|
+
|
|
288
|
+
Unregisters a search engine.
|
|
289
|
+
|
|
290
|
+
#### Parameters
|
|
291
|
+
|
|
292
|
+
##### name?
|
|
293
|
+
|
|
294
|
+
The name or class to unregister.
|
|
295
|
+
|
|
296
|
+
`string` | *typeof* `WebSearcher`
|
|
297
|
+
|
|
298
|
+
#### Returns
|
|
299
|
+
|
|
300
|
+
`void`
|
|
301
|
+
|
|
302
|
+
## Accessors
|
|
303
|
+
|
|
304
|
+
### pagination
|
|
305
|
+
|
|
306
|
+
#### Get Signature
|
|
307
|
+
|
|
308
|
+
> **get** **pagination**(): [`PaginationConfig`](../interfaces/PaginationConfig.md) \| `undefined`
|
|
309
|
+
|
|
310
|
+
Defined in: [web-searcher/src/searcher.ts:151](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L151)
|
|
311
|
+
|
|
312
|
+
Optional pagination configuration.
|
|
313
|
+
Defines how the searcher navigates to subsequent pages.
|
|
314
|
+
|
|
315
|
+
If undefined, the searcher will only fetch the first page.
|
|
316
|
+
|
|
317
|
+
##### Returns
|
|
318
|
+
|
|
319
|
+
[`PaginationConfig`](../interfaces/PaginationConfig.md) \| `undefined`
|
|
320
|
+
|
|
321
|
+
***
|
|
322
|
+
|
|
323
|
+
### template
|
|
324
|
+
|
|
325
|
+
#### Get Signature
|
|
326
|
+
|
|
327
|
+
> **get** `abstract` **template**(): `FetcherOptions`
|
|
328
|
+
|
|
329
|
+
Defined in: [web-searcher/src/searcher.ts:143](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L143)
|
|
330
|
+
|
|
331
|
+
The declarative template for the fetch options.
|
|
332
|
+
|
|
333
|
+
Subclasses **must** implement this getter to provide the engine configuration,
|
|
334
|
+
including the base URL, search parameters pattern, and extraction rules.
|
|
335
|
+
|
|
336
|
+
Supports variable injection using syntax like `${query}`, `${offset}`, etc.
|
|
337
|
+
|
|
338
|
+
##### Example
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
get template() {
|
|
342
|
+
return {
|
|
343
|
+
url: 'https://example.com/search?q=${query}',
|
|
344
|
+
actions: [ ... ]
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
##### Returns
|
|
350
|
+
|
|
351
|
+
`FetcherOptions`
|
|
352
|
+
|
|
353
|
+
## Methods
|
|
354
|
+
|
|
355
|
+
### createContext()
|
|
356
|
+
|
|
357
|
+
> `protected` **createContext**(`options`): `FetchContext`
|
|
358
|
+
|
|
359
|
+
Defined in: [web-searcher/src/searcher.ts:155](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L155)
|
|
360
|
+
|
|
361
|
+
#### Parameters
|
|
362
|
+
|
|
363
|
+
##### options
|
|
364
|
+
|
|
365
|
+
`FetcherOptions` = `...`
|
|
366
|
+
|
|
367
|
+
#### Returns
|
|
368
|
+
|
|
369
|
+
`FetchContext`
|
|
370
|
+
|
|
371
|
+
#### Overrides
|
|
372
|
+
|
|
373
|
+
`FetchSession.createContext`
|
|
374
|
+
|
|
375
|
+
***
|
|
376
|
+
|
|
377
|
+
### dispose()
|
|
378
|
+
|
|
379
|
+
> **dispose**(): `Promise`\<`void`\>
|
|
380
|
+
|
|
381
|
+
Defined in: web-fetcher/dist/index.d.ts:2251
|
|
382
|
+
|
|
383
|
+
Disposes of the session and its associated engine.
|
|
384
|
+
|
|
385
|
+
#### Returns
|
|
386
|
+
|
|
387
|
+
`Promise`\<`void`\>
|
|
388
|
+
|
|
389
|
+
#### Remarks
|
|
390
|
+
|
|
391
|
+
This method should be called when the session is no longer needed to free up resources
|
|
392
|
+
(e.g., closing browser instances, purging temporary storage).
|
|
393
|
+
|
|
394
|
+
#### Inherited from
|
|
395
|
+
|
|
396
|
+
`FetchSession.dispose`
|
|
397
|
+
|
|
398
|
+
***
|
|
399
|
+
|
|
400
|
+
### execute()
|
|
401
|
+
|
|
402
|
+
> **execute**\<`R`\>(`actionOptions`, `context?`): `Promise`\<`FetchActionResult`\<`R`\>\>
|
|
403
|
+
|
|
404
|
+
Defined in: web-fetcher/dist/index.d.ts:2206
|
|
405
|
+
|
|
406
|
+
Executes a single action within the session.
|
|
407
|
+
|
|
408
|
+
#### Type Parameters
|
|
409
|
+
|
|
410
|
+
##### R
|
|
411
|
+
|
|
412
|
+
`R` *extends* `FetchReturnType` = `"response"`
|
|
413
|
+
|
|
414
|
+
The expected return type of the action.
|
|
415
|
+
|
|
416
|
+
#### Parameters
|
|
417
|
+
|
|
418
|
+
##### actionOptions
|
|
419
|
+
|
|
420
|
+
`_RequireAtLeastOne`
|
|
421
|
+
|
|
422
|
+
Configuration for the action to be executed.
|
|
423
|
+
|
|
424
|
+
##### context?
|
|
425
|
+
|
|
426
|
+
`FetchContext`
|
|
427
|
+
|
|
428
|
+
Optional context override for this specific execution. Defaults to the session context.
|
|
429
|
+
|
|
430
|
+
#### Returns
|
|
431
|
+
|
|
432
|
+
`Promise`\<`FetchActionResult`\<`R`\>\>
|
|
433
|
+
|
|
434
|
+
A promise that resolves to the result of the action.
|
|
435
|
+
|
|
436
|
+
#### Example
|
|
437
|
+
|
|
438
|
+
```ts
|
|
439
|
+
await session.execute({ name: 'goto', params: { url: 'https://example.com' } });
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
#### Inherited from
|
|
443
|
+
|
|
444
|
+
`FetchSession.execute`
|
|
445
|
+
|
|
446
|
+
***
|
|
447
|
+
|
|
448
|
+
### executeAll()
|
|
449
|
+
|
|
450
|
+
> **executeAll**(`actions`, `options?`): `Promise`\<\{ `outputs`: `Record`\<`string`, `any`\>; `result`: `FetchResponse` \| `undefined`; \}\>
|
|
451
|
+
|
|
452
|
+
Defined in: web-fetcher/dist/index.d.ts:2223
|
|
453
|
+
|
|
454
|
+
Executes a sequence of actions.
|
|
455
|
+
|
|
456
|
+
#### Parameters
|
|
457
|
+
|
|
458
|
+
##### actions
|
|
459
|
+
|
|
460
|
+
`_RequireAtLeastOne`\<`FetchActionProperties`, `"id"` \| `"name"` \| `"action"`\>[]
|
|
461
|
+
|
|
462
|
+
An array of action options to be executed in order.
|
|
463
|
+
|
|
464
|
+
##### options?
|
|
465
|
+
|
|
466
|
+
`Partial`\<`FetcherOptions`\> & `object`
|
|
467
|
+
|
|
468
|
+
Optional temporary configuration overrides (e.g., timeoutMs, headers) for this batch of actions.
|
|
469
|
+
These overrides do not affect the main session context.
|
|
470
|
+
|
|
471
|
+
#### Returns
|
|
472
|
+
|
|
473
|
+
`Promise`\<\{ `outputs`: `Record`\<`string`, `any`\>; `result`: `FetchResponse` \| `undefined`; \}\>
|
|
474
|
+
|
|
475
|
+
A promise that resolves to an object containing the result of the last action and all accumulated outputs.
|
|
476
|
+
|
|
477
|
+
#### Example
|
|
478
|
+
|
|
479
|
+
```ts
|
|
480
|
+
const { result, outputs } = await session.executeAll([
|
|
481
|
+
{ name: 'goto', params: { url: 'https://example.com' } },
|
|
482
|
+
{ name: 'extract', params: { schema: { title: 'h1' } }, storeAs: 'data' }
|
|
483
|
+
], { timeoutMs: 30000 });
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
#### Inherited from
|
|
487
|
+
|
|
488
|
+
`FetchSession.executeAll`
|
|
489
|
+
|
|
490
|
+
***
|
|
491
|
+
|
|
492
|
+
### formatOptions()
|
|
493
|
+
|
|
494
|
+
> `protected` **formatOptions**(`options`): `Record`\<`string`, `any`\>
|
|
495
|
+
|
|
496
|
+
Defined in: [web-searcher/src/searcher.ts:308](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L308)
|
|
497
|
+
|
|
498
|
+
Transforms standard options into engine-specific template variables.
|
|
499
|
+
|
|
500
|
+
Subclasses should override this to map standard options like 'timeRange',
|
|
501
|
+
'category', 'region' into the specific URL parameters required by the engine
|
|
502
|
+
(e.g., mapping `timeRange: 'day'` to `tbs: 'qdr:d'` for Google).
|
|
503
|
+
|
|
504
|
+
#### Parameters
|
|
505
|
+
|
|
506
|
+
##### options
|
|
507
|
+
|
|
508
|
+
[`SearchOptions`](../interfaces/SearchOptions.md)
|
|
509
|
+
|
|
510
|
+
The search options provided by the user.
|
|
511
|
+
|
|
512
|
+
#### Returns
|
|
513
|
+
|
|
514
|
+
`Record`\<`string`, `any`\>
|
|
515
|
+
|
|
516
|
+
A dictionary of variables to be injected into the template.
|
|
517
|
+
|
|
518
|
+
***
|
|
519
|
+
|
|
520
|
+
### getOutputs()
|
|
521
|
+
|
|
522
|
+
> **getOutputs**(): `Record`\<`string`, `any`\>
|
|
523
|
+
|
|
524
|
+
Defined in: web-fetcher/dist/index.d.ts:2234
|
|
525
|
+
|
|
526
|
+
Retrieves all outputs accumulated during the session.
|
|
527
|
+
|
|
528
|
+
#### Returns
|
|
529
|
+
|
|
530
|
+
`Record`\<`string`, `any`\>
|
|
531
|
+
|
|
532
|
+
A record of stored output data.
|
|
533
|
+
|
|
534
|
+
#### Inherited from
|
|
535
|
+
|
|
536
|
+
`FetchSession.getOutputs`
|
|
537
|
+
|
|
538
|
+
***
|
|
539
|
+
|
|
540
|
+
### getState()
|
|
541
|
+
|
|
542
|
+
> **getState**(): `Promise`\<\{ `cookies`: `Cookie`[]; `sessionState?`: `any`; \} \| `undefined`\>
|
|
543
|
+
|
|
544
|
+
Defined in: web-fetcher/dist/index.d.ts:2240
|
|
545
|
+
|
|
546
|
+
Gets the current state of the session, including cookies and engine-specific state.
|
|
547
|
+
|
|
548
|
+
#### Returns
|
|
549
|
+
|
|
550
|
+
`Promise`\<\{ `cookies`: `Cookie`[]; `sessionState?`: `any`; \} \| `undefined`\>
|
|
551
|
+
|
|
552
|
+
A promise resolving to the session state, or undefined if no engine is initialized.
|
|
553
|
+
|
|
554
|
+
#### Inherited from
|
|
555
|
+
|
|
556
|
+
`FetchSession.getState`
|
|
557
|
+
|
|
558
|
+
***
|
|
559
|
+
|
|
560
|
+
### search()
|
|
561
|
+
|
|
562
|
+
> **search**(`query`, `options`): `Promise`\<[`StandardSearchResult`](../interfaces/StandardSearchResult.md)[]\>
|
|
563
|
+
|
|
564
|
+
Defined in: [web-searcher/src/searcher.ts:182](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L182)
|
|
565
|
+
|
|
566
|
+
Executes a search query.
|
|
567
|
+
|
|
568
|
+
This method handles the pagination loop, variable injection, fetching,
|
|
569
|
+
and result transformation.
|
|
570
|
+
|
|
571
|
+
#### Parameters
|
|
572
|
+
|
|
573
|
+
##### query
|
|
574
|
+
|
|
575
|
+
`string`
|
|
576
|
+
|
|
577
|
+
The search query string.
|
|
578
|
+
|
|
579
|
+
##### options
|
|
580
|
+
|
|
581
|
+
[`SearchOptions`](../interfaces/SearchOptions.md) = `{}`
|
|
582
|
+
|
|
583
|
+
Optional search parameters (e.g., limit, timeRange).
|
|
584
|
+
|
|
585
|
+
#### Returns
|
|
586
|
+
|
|
587
|
+
`Promise`\<[`StandardSearchResult`](../interfaces/StandardSearchResult.md)[]\>
|
|
588
|
+
|
|
589
|
+
A promise resolving to an array of standardized search results.
|
|
590
|
+
|
|
591
|
+
***
|
|
592
|
+
|
|
593
|
+
### transform()
|
|
594
|
+
|
|
595
|
+
> `protected` **transform**(`outputs`, `context`): `Promise`\<[`StandardSearchResult`](../interfaces/StandardSearchResult.md)[]\>
|
|
596
|
+
|
|
597
|
+
Defined in: [web-searcher/src/searcher.ts:290](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L290)
|
|
598
|
+
|
|
599
|
+
Transform and clean the raw extracted results.
|
|
600
|
+
|
|
601
|
+
Subclasses should override this method to provide engine-specific cleaning,
|
|
602
|
+
normalization, or post-processing of the data extracted by the fetcher.
|
|
603
|
+
|
|
604
|
+
#### Parameters
|
|
605
|
+
|
|
606
|
+
##### outputs
|
|
607
|
+
|
|
608
|
+
`Record`\<`string`, `any`\>
|
|
609
|
+
|
|
610
|
+
The complete outputs object from the fetch actions.
|
|
611
|
+
|
|
612
|
+
##### context
|
|
613
|
+
|
|
614
|
+
[`SearchContext`](../interfaces/SearchContext.md)
|
|
615
|
+
|
|
616
|
+
The search context (query, page, etc.).
|
|
617
|
+
|
|
618
|
+
#### Returns
|
|
619
|
+
|
|
620
|
+
`Promise`\<[`StandardSearchResult`](../interfaces/StandardSearchResult.md)[]\>
|
|
621
|
+
|
|
622
|
+
A promise resolving to an array of standardized search results.
|
|
623
|
+
|
|
624
|
+
***
|
|
625
|
+
|
|
626
|
+
### search()
|
|
627
|
+
|
|
628
|
+
> `static` **search**(`engineName`, `query`, `options`): `Promise`\<[`StandardSearchResult`](../interfaces/StandardSearchResult.md)[]\>
|
|
629
|
+
|
|
630
|
+
Defined in: [web-searcher/src/searcher.ts:106](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/searcher.ts#L106)
|
|
631
|
+
|
|
632
|
+
Static helper to execute a one-off search.
|
|
633
|
+
|
|
634
|
+
It creates an instance of the specified engine, executes the search, and then
|
|
635
|
+
automatically disposes of the session.
|
|
636
|
+
|
|
637
|
+
#### Parameters
|
|
638
|
+
|
|
639
|
+
##### engineName
|
|
640
|
+
|
|
641
|
+
`string`
|
|
642
|
+
|
|
643
|
+
The name of the engine to use (e.g., 'Google').
|
|
644
|
+
|
|
645
|
+
##### query
|
|
646
|
+
|
|
647
|
+
`string`
|
|
648
|
+
|
|
649
|
+
The search query string.
|
|
650
|
+
|
|
651
|
+
##### options
|
|
652
|
+
|
|
653
|
+
[`SearchOptions`](../interfaces/SearchOptions.md) & `FetcherOptions` = `{}`
|
|
654
|
+
|
|
655
|
+
Combined search options and fetcher options.
|
|
656
|
+
|
|
657
|
+
#### Returns
|
|
658
|
+
|
|
659
|
+
`Promise`\<[`StandardSearchResult`](../interfaces/StandardSearchResult.md)[]\>
|
|
660
|
+
|
|
661
|
+
A promise resolving to an array of standardized search results.
|
package/docs/globals.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[**@isdk/web-searcher**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# @isdk/web-searcher
|
|
6
|
+
|
|
7
|
+
## Classes
|
|
8
|
+
|
|
9
|
+
- [GoogleSearcher](classes/GoogleSearcher.md)
|
|
10
|
+
- [WebSearcher](classes/WebSearcher.md)
|
|
11
|
+
|
|
12
|
+
## Interfaces
|
|
13
|
+
|
|
14
|
+
- [CustomTimeRange](interfaces/CustomTimeRange.md)
|
|
15
|
+
- [PaginationConfig](interfaces/PaginationConfig.md)
|
|
16
|
+
- [SearchContext](interfaces/SearchContext.md)
|
|
17
|
+
- [SearchOptions](interfaces/SearchOptions.md)
|
|
18
|
+
- [StandardSearchResult](interfaces/StandardSearchResult.md)
|
|
19
|
+
|
|
20
|
+
## Type Aliases
|
|
21
|
+
|
|
22
|
+
- [SafeSearchLevel](type-aliases/SafeSearchLevel.md)
|
|
23
|
+
- [SearchCategory](type-aliases/SearchCategory.md)
|
|
24
|
+
- [SearcherConstructor](type-aliases/SearcherConstructor.md)
|
|
25
|
+
- [SearchTimeRange](type-aliases/SearchTimeRange.md)
|
|
26
|
+
- [SearchTimeRangePreset](type-aliases/SearchTimeRangePreset.md)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[**@isdk/web-searcher**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/web-searcher](../globals.md) / CustomTimeRange
|
|
6
|
+
|
|
7
|
+
# Interface: CustomTimeRange
|
|
8
|
+
|
|
9
|
+
Defined in: [web-searcher/src/types.ts:78](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/types.ts#L78)
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### from
|
|
14
|
+
|
|
15
|
+
> **from**: `string` \| `Date`
|
|
16
|
+
|
|
17
|
+
Defined in: [web-searcher/src/types.ts:80](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/types.ts#L80)
|
|
18
|
+
|
|
19
|
+
Start date (Date object or string like 'YYYY-MM-DD').
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### to?
|
|
24
|
+
|
|
25
|
+
> `optional` **to**: `string` \| `Date`
|
|
26
|
+
|
|
27
|
+
Defined in: [web-searcher/src/types.ts:82](https://github.com/isdk/web-searcher.js/blob/e9a6e5ec9526780489427743389b927a5c16db5c/src/types.ts#L82)
|
|
28
|
+
|
|
29
|
+
End date (Date object or string like 'YYYY-MM-DD'). Defaults to current date if omitted.
|