@@ -45,9 +45,9 @@ Create a crawler instance via new XCrawl.
45
45
class XCrawl {
46
46
private readonly baseConfig
47
47
constructor (baseConfig ?: IXCrawlBaseConifg )
48
+ fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
48
49
fetchData<T = any>(config: IFetchDataConfig): Promise<IFetchCommon<T>>
49
50
fetchFile(config: IFetchFileConfig): Promise<IFetchCommon<IFileInfo>>
50
- fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
51
51
}
52
52
` ` `
53
53
@@ -67,6 +67,24 @@ const myXCrawl = new XCrawl({
67
67
})
68
68
` ` `
69
69
70
+ ### fetchHTML
71
+
72
+ fetchHTML is the method of the above <a href="#myXCrawl" style="text-decoration: none">myXCrawl</a> instance, usually used to crawl HTML.
73
+
74
+ - Type
75
+
76
+ ` ` ` ts
77
+ function fetchHTML (config : string | IFetchHTMLConfig ): Promise<JSDOM>
78
+ ```
79
+
80
+ - Example
81
+
82
+ ```js
83
+ myXCrawl.fetchHTML('/xxx').then((jsdom) => {
84
+ console .log (jsdom .window .document .querySelector (' title' )? .textContent )
85
+ })
86
+ ` ` `
87
+
70
88
### fetchData
71
89
72
90
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.
@@ -123,24 +141,6 @@ myXCrawl.fetchFile({
123
141
})
124
142
` ` `
125
143
126
- ### fetchHTML
127
-
128
- fetchHTML is the method of the above <a href="#myXCrawl" style="text-decoration: none">myXCrawl</a> instance, usually used to crawl HTML.
129
-
130
- - Type
131
-
132
- ` ` ` ts
133
- function fetchHTML (config : string | IFetchHTMLConfig ): Promise<JSDOM>
134
- ```
135
-
136
- - Example
137
-
138
- ```js
139
- myXCrawl.fetchHTML('/xxx').then((jsdom) => {
140
- console .log (jsdom .window .document .querySelector (' title' )? .textContent )
141
- })
142
- ` ` `
143
-
144
144
## Types
145
145
146
146
- IAnyObject
@@ -220,6 +220,12 @@ interface IXCrawlBaseConifg {
220
220
}
221
221
` ` `
222
222
223
+ - IFetchHTMLConfig
224
+
225
+ ` ` ` ts
226
+ interface IFetchHTMLConfig extends IRequestConfig {}
227
+ ` ` `
228
+
223
229
- IFetchDataConfig
224
230
225
231
` ` ` ts
@@ -237,12 +243,6 @@ interface IFetchFileConfig extends IFetchBaseConifg {
237
243
}
238
244
` ` `
239
245
240
- - IFetchHTMLConfig
241
-
242
- ` ` ` ts
243
- interface IFetchHTMLConfig extends IRequestConfig {}
244
- ` ` `
245
-
246
246
## More
247
247
248
248
If you have any **questions** or **needs** , please submit **Issues in** https://github.com/coder-hxl/x-crawl/issues .
@@ -298,9 +298,9 @@ docsXCrawl.fetchHTML('/zh/get-started').then((jsdom) => {
298
298
class XCrawl {
299
299
private readonly baseConfig
300
300
constructor(baseConfig?: IXCrawlBaseConifg)
301
+ fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
301
302
fetchData<T = any>(config: IFetchDataConfig): Promise<IFetchCommon<T>>
302
303
fetchFile(config: IFetchFileConfig): Promise<IFetchCommon<IFileInfo>>
303
- fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
304
304
}
305
305
` ` `
306
306
@@ -347,6 +347,24 @@ myXCrawl.fetchData({
347
347
})
348
348
` ` `
349
349
350
+ ### fetchHTML
351
+
352
+ fetchHTML 是上面 < a href= " #cn-myXCrawl" style= " text-decoration: none" > myXCrawl< / a> 实例的方法,通常用于爬取 HTML 。
353
+
354
+ - 类型
355
+
356
+ ` ` ` ts
357
+ function fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
358
+ ` ` `
359
+
360
+ - 示例
361
+
362
+ ` ` ` js
363
+ myXCrawl.fetchHTML('/xxx').then((jsdom) => {
364
+ console.log(jsdom.window.document.querySelector('title')?.textContent)
365
+ })
366
+ ` ` `
367
+
350
368
### fetchFile
351
369
352
370
fetchFile 是上面 < a href= " #cn-myXCrawl" style= " text-decoration: none" > myXCrawl< / a> 实例的方法,通常用于爬取文件,可获取图片、pdf 文件等等。
@@ -376,24 +394,6 @@ myXCrawl.fetchFile({
376
394
})
377
395
` ` `
378
396
379
- ### fetchHTML
380
-
381
- fetchHTML 是上面 < a href= " #cn-myXCrawl" style= " text-decoration: none" > myXCrawl< / a> 实例的方法,通常用于爬取 HTML 。
382
-
383
- - 类型
384
-
385
- ` ` ` ts
386
- function fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
387
- ` ` `
388
-
389
- - 示例
390
-
391
- ` ` ` js
392
- myXCrawl.fetchHTML('/xxx').then((jsdom) => {
393
- console.log(jsdom.window.document.querySelector('title')?.textContent)
394
- })
395
- ` ` `
396
-
397
397
## 类型
398
398
399
399
- IAnyObject
@@ -473,6 +473,12 @@ interface IXCrawlBaseConifg {
473
473
}
474
474
` ` `
475
475
476
+ - IFetchHTMLConfig
477
+
478
+ ` ` ` ts
479
+ interface IFetchHTMLConfig extends IRequestConfig {}
480
+ ` ` `
481
+
476
482
- IFetchDataConfig
477
483
478
484
` ` ` ts
@@ -490,12 +496,6 @@ interface IFetchFileConfig extends IFetchBaseConifg {
490
496
}
491
497
` ` `
492
498
493
- - IFetchHTMLConfig
494
-
495
- ` ` ` ts
496
- interface IFetchHTMLConfig extends IRequestConfig {}
497
- ` ` `
498
-
499
499
## 更多
500
500
501
501
如有 ** 问题** 或 ** 需求** 请在 https: // github.com/coder-hxl/x-crawl/issues 中提 **Issues** 。
0 commit comments