@@ -45,7 +45,7 @@ Create a crawler instance via new XCrawl.
45
45
class XCrawl {
46
46
private readonly baseConfig
47
47
constructor (baseConfig ?: IXCrawlBaseConifg )
48
- fetch <T = any>(config: IFetchConfig ): Promise<IFetch <T>>
48
+ fetchData <T = any>(config: IFetchDataConfig ): Promise<IFetchData <T>>
49
49
fetchFile(config: IFetchFileConfig): Promise<IFetchFile>
50
50
fetchHTML(url: string): Promise<JSDOM>
51
51
}
@@ -67,14 +67,14 @@ const myXCrawl = new XCrawl({
67
67
})
68
68
` ` `
69
69
70
- ### fetch
70
+ ### fetchData
71
71
72
- fetch is the method of the above <a href="#myXCrawl" style="text-decoration: none">myXCrawl</a> instance, which is usually used to crawl APIs to obtain JSON data and so on.
72
+ fetchData is the method of the above <a href="#myXCrawl" style="text-decoration: none">myXCrawl</a> instance, which is usually used to crawl APIs to obtain JSON data and so on.
73
73
74
74
- Type
75
75
76
76
` ` ` ts
77
- function fetch <T = any>(config : IFetchConfig ): Promise<T>
77
+ function fetchData <T = any>(config : IFetchDataConfig ): Promise<T>
78
78
```
79
79
80
80
- Example
@@ -86,7 +86,7 @@ const requestConifg = [
86
86
{ url: ' /xxxx' , method: ' GET' }
87
87
]
88
88
89
- myXCrawl .fetch ({
89
+ myXCrawl .fetchData ({
90
90
requestConifg, // Request configuration, can be IRequestConfig | IRequestConfig[]
91
91
intervalTime: 800 // Interval between next requests, multiple requests are valid
92
92
}).then (res => {
@@ -188,10 +188,10 @@ interface IFetchBaseConifg {
188
188
}
189
189
` ` `
190
190
191
- - IFech
191
+ - IFechData
192
192
193
193
` ` ` ts
194
- type IFetch < T > = {
194
+ type IFetchData < T > = {
195
195
statusCode: number | undefined
196
196
headers: IncomingHttpHeaders // node:http
197
197
data: T
@@ -219,10 +219,10 @@ interface IXCrawlBaseConifg {
219
219
}
220
220
` ` `
221
221
222
- - IFetchConfig
222
+ - IFetchDataConfig
223
223
224
224
` ` ` ts
225
- interface IFetchConfig extends IFetchBaseConifg {
225
+ interface IFetchDataConfig extends IFetchBaseConifg {
226
226
}
227
227
` ` `
228
228
@@ -291,7 +291,7 @@ docsXCrawl.fetchHTML('/zh/get-started').then((jsdom) => {
291
291
class XCrawl {
292
292
private readonly baseConfig
293
293
constructor(baseConfig?: IXCrawlBaseConifg)
294
- fetch <T = any>(config: IFetchConfig ): Promise<IFetch <T>>
294
+ fetchData <T = any>(config: IFetchDataConfig ): Promise<IFetchData <T>>
295
295
fetchFile(config: IFetchFileConfig): Promise<IFetchFile>
296
296
fetchHTML(url: string): Promise<JSDOM>
297
297
}
@@ -313,14 +313,14 @@ const myXCrawl = new XCrawl({
313
313
})
314
314
` ` `
315
315
316
- ### fetch
316
+ ### fetchData
317
317
318
318
fetch 是上面 < a href= " #cn-myXCrawl" style= " text-decoration: none" > myXCrawl< / a> 实例的方法,通常用于爬取 API ,可获取 JSON 数据等等。
319
319
320
320
- 类型
321
321
322
322
` ` ` ts
323
- function fetch <T = any>(config: IFetchConfig ): Promise<T>
323
+ function fetchData <T = any>(config: IFetchDataConfig ): Promise<T>
324
324
` ` `
325
325
326
326
- 示例
@@ -332,7 +332,7 @@ const requestConifg = [
332
332
{ url: '/xxxx', method: 'GET' }
333
333
]
334
334
335
- myXCrawl.fetch ({
335
+ myXCrawl.fetchData ({
336
336
requestConifg, // 请求配置, 可以是 IRequestConfig | IRequestConfig[]
337
337
intervalTime: 800 // 下次请求的间隔时间, 多个请求才有效
338
338
}).then(res => {
@@ -434,7 +434,7 @@ interface IFetchBaseConifg {
434
434
}
435
435
` ` `
436
436
437
- - IFetch
437
+ - IFetchData
438
438
439
439
` ` ` ts
440
440
type IFetch<T> = {
@@ -465,10 +465,10 @@ interface IXCrawlBaseConifg {
465
465
}
466
466
` ` `
467
467
468
- - IFetchConfig
468
+ - IFetchDataConfig
469
469
470
470
` ` ` ts
471
- interface IFetchConfig extends IFetchBaseConifg {
471
+ interface IFetchDataConfig extends IFetchBaseConifg {
472
472
}
473
473
` ` `
474
474
0 commit comments