Skip to content

Commit

Permalink
docs(type): use a table to show the types
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-hxl committed Jul 21, 2024
1 parent 634f909 commit f9d4c24
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 120 deletions.
32 changes: 16 additions & 16 deletions docs/cn/type/crawl-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export interface CrawlDataDetailTargetConfig extends CrawlCommonConfig {
}
```

**默认值**

- url: undefined
- method: 'GET'
- headers: undefined
- params: undefined
- data: undefined
- priority: undefined
- fingerprint: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ----------- | ----------------------------- | ------ | ---------- |
| url | string | - | url |
| method | Method | `GET` | 方法 |
| headers | Object \\| null | - | 请求头 |
| params | IntervalTime | - | Query 参数 |
| data | any | - | 请求体 |
| priority | number | - | 优先级 |
| fingerprint | DetailTargetFingerprintCommon | - | 设备指纹 |

## CrawlDataAdvancedConfig

Expand All @@ -40,13 +40,13 @@ export interface CrawlDataAdvancedConfig<T> extends CrawlCommonConfig {
}
```

**默认值**

- targets: undefined
- intervalTime: undefined
- fingerprints: undefined
- headers: undefined
- onCrawlItemComplete: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ------------------- | -------------------------------------------------------- | ------------------------------ | -------- |
| targets | (string \\| CrawlDataDetailTargetConfig)[] | - | 目标 |
| intervalTime | IntervalTime | - | 间隔时间 |
| fingerprints | DetailTargetFingerprintCommon[] | - | 设备指纹 |
| headers | Object | - | 请求头 |
| onCrawlItemComplete | ( crawlDataSingleResult: CrawlDataSingleResult ) => void | - | 声明周期 |

## CrawlDataSingleResult

Expand Down
40 changes: 20 additions & 20 deletions docs/cn/type/crawl-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export interface CrawlFileDetailTargetConfig extends CrawlCommonConfig {
}
```

**默认值**

- url: undefined
- headers: undefined
- priority: undefined
- storeDir: \_\_dirname
- fileName: string
- extension: string
- fingerprint: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ----------- | ----------------------------- | ----------- | -------- |
| url | string | - | url |
| headers | Object \\| null | - | 请求头 |
| priority | number | - | 优先级 |
| storeDir | string | \_\_dirname | 存储位置 |
| fileName | string | - | 文件名 |
| extension | string | - | 扩展名 |
| fingerprint | DetailTargetFingerprintCommon | - | 设备指纹 |

## CrawlFileAdvancedConfig

Expand All @@ -47,17 +47,17 @@ export interface CrawlFileAdvancedConfig extends CrawlCommonConfig {
}
```

**默认值**

- targets: undefined
- intervalTime: undefined
- fingerprints: undefined
- storeDirs: \_\_dirname
- extensions: string
- fileNames: undefined
- headers: undefined
- onCrawlItemComplete: undefined
- onBeforeSaveItemFile: undefined
| 参数 | 类型 | 默认值 | 描述 |
| -------------------- | ------------------ | ------------------- | --------- |
| targets | (string \\| CrawlDataDetailTargetConfig)[] | - | 目标 |
| intervalTime | IntervalTime | - | 间隔时间 |
| fingerprints | DetailTargetFingerprintCommon[] | - | 设备指纹 |
| storeDirs | string \\| (string \\| null)[] | \_\_dirname | 存储位置 |
| extension | string \\| (string \\| null)[] | - | 扩展名 |
| fileName | (string \\| null)[] | - | 文件名 |
| headers | Object | - | 请求头 |
| onCrawlItemComplete | ( crawlDataSingleResult: CrawlDataSingleResult ) => void | - | 声明周期 |
| onBeforeSaveItemFile | (info: { id: number; fileName: string; filePath: string; data: Buffer }) => Promise<Buffer \\| void> \\| Buffer \\| void | - | 声明周期 |

## CrawlFileSingleResult

Expand Down
26 changes: 13 additions & 13 deletions docs/cn/type/crawl-html.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export interface CrawlHTMLDetailTargetConfig extends CrawlCommonConfig {
}
```

**默认值**

- url: undefined
- headers: undefined
- priority: undefined
- fingerprint: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ----------- | ----------------------------- | ------ | -------- |
| url | string | - | url |
| headers | Object \\| null | - | 请求头 |
| priority | number | - | 优先级 |
| fingerprint | DetailTargetFingerprintCommon | - | 设备指纹 |

## CrawlHTMLAdvancedConfig

Expand All @@ -32,13 +32,13 @@ export interface CrawlHTMLAdvancedConfig extends CrawlCommonConfig {
}
```

**默认值**

- targets: undefined
- intervalTime: undefined
- fingerprints: undefined
- headers: undefined
- onCrawlItemComplete: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ------------------- | -------------------------------------------------------- | ------------------------------ | -------- |
| targets | (string \\| CrawlDataDetailTargetConfig)[] | - | 目标 |
| intervalTime | IntervalTime | - | 间隔时间 |
| fingerprints | DetailTargetFingerprintCommon[] | - | 设备指纹 |
| headers | Object | - | 请求头 |
| onCrawlItemComplete | ( crawlDataSingleResult: CrawlDataSingleResult ) => void | - | 声明周期 |

## CrawlHTMLSingleResult

Expand Down
8 changes: 3 additions & 5 deletions docs/cn/type/crawl-openai-other-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export interface CrawlOpenAICommonAPIOtherOption {
}
```

- model:要选择的 AI 模型。

**默认值**

- model: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ----- | -- | -- | --- |
| model | 'gpt-4-0125-preview' \\| 'gpt-4-turbo-preview' \\| 'gpt-4-1106-preview' \\| 'gpt-4-vision-preview' \\| 'gpt-4' \\| 'gpt-4-0314' \\| 'gpt-4-0613' \\| 'gpt-4-32k' \\| 'gpt-4-32k-0314' \\| 'gpt-4-32k-0613' \\| 'gpt-3.5-turbo' \\| 'gpt-3.5-turbo-16k' \\| 'gpt-3.5-turbo-0301' \\| 'gpt-3.5-turbo-0613' \\| 'gpt-3.5-turbo-1106' \\| 'gpt-3.5-turbo-0125' \\| 'gpt-3.5-turbo-16k-0613' | - | AI 模型 |
34 changes: 17 additions & 17 deletions docs/cn/type/crawl-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export interface CrawlPageDetailTargetConfig extends CrawlCommonConfig {
}
```

**默认值**

- url: undefined
- headers: undefined
- cookies: undefined
- priority: undefined
- viewport: undefined
- fingerprint: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ----------- | --- | ------ | ------------ |
| url | string | - | url |
| headers | Object \\| null | - | 请求头 |
| cookies | PageCookies \\| null | - | cookies |
| priority | number | - | 优先级 |
| viewport | Viewport | - | 设置视口大小 |
| fingerprint | DetailTargetFingerprintCommon & { maxWidth?: number; minWidth?: number; maxHeight?: number; minHidth?: number }) | - | 设备指纹 |

**外部类型**

Expand All @@ -54,15 +54,15 @@ export interface CrawlPageAdvancedConfig extends CrawlCommonConfig {
}
```

**默认值**

- targets: undefined
- intervalTime: undefined
- fingerprints: undefined
- headers: undefined
- cookies: undefined
- viewport: undefined
- onCrawlItemComplete: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ------------------- | -------------------------------------------------------- | ------------------------------ | ------------ |
| targets | (string \\| CrawlDataDetailTargetConfig)[] | - | 目标 |
| intervalTime | IntervalTime | - | 间隔时间 |
| fingerprints | DetailTargetFingerprintCommon[] | - | 设备指纹 |
| headers | Object | - | 请求头 |
| cookies | PageCookies | null | - | cookies |
| viewport | Viewport | - | 设置视口大小 |
| onCrawlItemComplete | ( crawlDataSingleResult: CrawlDataSingleResult ) => void | - | 声明周期 |

**外部类型**

Expand Down
8 changes: 4 additions & 4 deletions docs/cn/type/create-crawl-openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export interface CreateCrawlOpenAIConfig {
}
```

**默认值**

- defaultModel: { chatModel: 'gpt-3.5-turbo' }
- clientOptions: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ------------- | ------------------------------ | ------ | ----------------------------- |
| defaultModel | { chatModel: OpenAIChatModel } | - | AI 模型 |
| clientOptions | ClientOptions | - | AI 其他配置, 用于创建 AI 实例 |

**外部类型**

Expand Down
26 changes: 13 additions & 13 deletions docs/cn/type/get-element-selectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ export interface CrawlOpenAIGetElementSelectorsContentOptions {
}
```

- pathMode:
- strict:选择器的路径从根部元素开始, 并精确指向目标元素。
- default:可以从任何级别的元素开始的选择器。

**默认值**

- message: undefined
- pathMode: 'default'
| 参数 | 类型 | 默认值 | 描述 |
| -------- | ------------ | -------- | ------------------------------------------------ |
| message | string | - | 你需要 AI 做的操作 |
| pathMode | 'default' \\| 'strict' | 'default' | 类型 |
| | strict | - | 选择器的路径从根部元素开始, 并精确指向目标元素。 |
| | default | - | 可以从任何级别的元素开始的选择器。 |

## CrawlOpenAIGetElementSelectorsResult

Expand All @@ -27,8 +25,10 @@ export interface CrawlOpenAIGetElementSelectorsResult {
}
```

- type

- single:说明当前 HTML 片段只找到一个目标。
- multiple: 说明当前 HTML 片段找到多个目标。
- none: 没有在当前 HTML 片段找到。
| 参数 | 类型 | 默认值 | 描述 |
| --------- | ----------- | ------------- | ---------------------------------- |
| selectors | string | - | 选择器 |
| type | 'single' \\| 'multiple' \\| 'none' | - | 类型 |
| | single | - | 说明当前 HTML 片段只找到一个目标。 |
| | multiple | - | 说明当前 HTML 片段找到多个目标。 |
| | none | - | 说明没有在当前 HTML 片段找到。 |
26 changes: 10 additions & 16 deletions docs/cn/type/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,21 @@ export interface CreateCrawlConfig extends CrawlCommonConfig {
enableRandomFingerprint?: boolean
baseUrl?: string
intervalTime?: IntervalTime
log?:
| {
start?: boolean
process?: boolean
result?: boolean
}
| boolean
log?: LogOptions | boolean
crawlPage?: {
puppeteerLaunchOptions?: PuppeteerLaunchOptions // PuppeteerLaunchOptions 来自于 puppeteer
puppeteerLaunchOptions?: PuppeteerLaunchOptions
}
}
```

**默认值**

- mode: 'async'
- enableRandomFingerprint: false
- baseUrl: undefined
- intervalTime: undefined
- log: { start: true, process: true, result: true }
- crawlPage: undefined
| 参数 | 类型 | 默认值 | 描述 |
| -- | -- | -- | -- |
| mode | `async` \\| `sync` | `async` | 设置爬取模式 |
| enableRandomFingerprint | boolean | false | 是否启动随机设备指纹 |
| baseUrl | string | - | 基础地址 |
| intervalTime | IntervalTime | - | 间隔时间 |
| log | { start: true; process: true; result: true } \\| boolean | true | 打印日志 |
| crawlPage | PuppeteerLaunchOptions | - | 传给 puppeteer.launch 用于创建浏览器实例 |

**外部类型**

Expand Down
17 changes: 10 additions & 7 deletions docs/cn/type/parse-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export interface CrawlOpenAIParseElementsContentOptions {
}
```

**默认值**

- message: undefined
| 参数 | 类型 | 默认值 | 描述 |
| ------- | ------ | ------ | ------------------ |
| message | string | - | 你需要 AI 做的操作 |

**外部类型**

Expand All @@ -27,7 +27,10 @@ export interface CrawlOpenAIParseElementsResult<
}
```

- type
- single:说明当前 HTML 片段只找到一个目标。
- multiple: 说明当前 HTML 片段找到多个目标。
- none: 没有在当前 HTML 片段找到。
| 参数 | 类型 | 默认值 | 描述 |
| -------- | ----------- | ------------- | ---------------------------------- |
| elements | T[] | - | 拿到的元素 |
| type | 'single' \\| 'multiple' \\| 'none' | - | 类型 |
| | single | - | 说明当前 HTML 片段只找到一个目标。 |
| | multiple | - | 说明当前 HTML 片段找到多个目标。 |
| | none | - | 说明没有在当前 HTML 片段找到。 |
18 changes: 9 additions & 9 deletions docs/type/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#createCrawl
# createCrawl

## CreateCrawlConfig

Expand All @@ -21,14 +21,14 @@ export interface CreateCrawlConfig extends CrawlCommonConfig {
}
```

**default value**

- mode: 'async'
- enableRandomFingerprint: false
- baseUrl: undefined
- intervalTime: undefined
- log: { start: true, process: true, result: true }
- crawlPage: undefined
| Parameter | Type | Default | Description |
| ----------------------- | -- | ------- | ------------------------------------------------------- |
| mode | `async` \\| `sync` | `async` | Set crawling mode |
| enableRandomFingerprint | boolean | false | Whether to enable random device fingerprint |
| baseUrl | string | - | Base URL |
| intervalTime | IntervalTime | - | Interval time |
| log | { start: true; process: true; result: true } \\| boolean | true | Print log |
| crawlPage | PuppeteerLaunchOptions | - | Passed to puppeteer.launch to create a browser instance |

**External type**

Expand Down

0 comments on commit f9d4c24

Please sign in to comment.