@@ -45,9 +45,9 @@ Create a crawler instance via new XCrawl.
4545class XCrawl {
4646 private readonly baseConfig
4747 constructor (baseConfig ?: IXCrawlBaseConifg )
48+ fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
4849 fetchData<T = any>(config: IFetchDataConfig): Promise<IFetchCommon<T>>
4950 fetchFile(config: IFetchFileConfig): Promise<IFetchCommon<IFileInfo>>
50- fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
5151}
5252` ` `
5353
@@ -67,6 +67,24 @@ const myXCrawl = new XCrawl({
6767})
6868` ` `
6969
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+
7088### fetchData
7189
7290fetchData 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({
123141})
124142` ` `
125143
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-
144144## Types
145145
146146- IAnyObject
@@ -220,6 +220,12 @@ interface IXCrawlBaseConifg {
220220}
221221` ` `
222222
223+ - IFetchHTMLConfig
224+
225+ ` ` ` ts
226+ interface IFetchHTMLConfig extends IRequestConfig {}
227+ ` ` `
228+
223229- IFetchDataConfig
224230
225231` ` ` ts
@@ -237,12 +243,6 @@ interface IFetchFileConfig extends IFetchBaseConifg {
237243}
238244` ` `
239245
240- - IFetchHTMLConfig
241-
242- ` ` ` ts
243- interface IFetchHTMLConfig extends IRequestConfig {}
244- ` ` `
245-
246246## More
247247
248248If 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) => {
298298class XCrawl {
299299 private readonly baseConfig
300300 constructor(baseConfig?: IXCrawlBaseConifg)
301+ fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
301302 fetchData<T = any>(config: IFetchDataConfig): Promise<IFetchCommon<T>>
302303 fetchFile(config: IFetchFileConfig): Promise<IFetchCommon<IFileInfo>>
303- fetchHTML(config: string | IFetchHTMLConfig): Promise<JSDOM>
304304}
305305` ` `
306306
@@ -347,6 +347,24 @@ myXCrawl.fetchData({
347347})
348348` ` `
349349
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+
350368### fetchFile
351369
352370fetchFile 是上面 < a href= " #cn-myXCrawl" style= " text-decoration: none" > myXCrawl< / a> 实例的方法,通常用于爬取文件,可获取图片、pdf 文件等等。
@@ -376,24 +394,6 @@ myXCrawl.fetchFile({
376394})
377395` ` `
378396
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-
397397## 类型
398398
399399- IAnyObject
@@ -473,6 +473,12 @@ interface IXCrawlBaseConifg {
473473}
474474` ` `
475475
476+ - IFetchHTMLConfig
477+
478+ ` ` ` ts
479+ interface IFetchHTMLConfig extends IRequestConfig {}
480+ ` ` `
481+
476482- IFetchDataConfig
477483
478484` ` ` ts
@@ -490,12 +496,6 @@ interface IFetchFileConfig extends IFetchBaseConifg {
490496}
491497` ` `
492498
493- - IFetchHTMLConfig
494-
495- ` ` ` ts
496- interface IFetchHTMLConfig extends IRequestConfig {}
497- ` ` `
498-
499499## 更多
500500
501501如有 ** 问题** 或 ** 需求** 请在 https: // github.com/coder-hxl/x-crawl/issues 中提 **Issues** 。
0 commit comments