> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/web-scraper-api/features/custom-parser/writing-instructions-manually/list-of-functions.md).

# 解析函数列表

您可以在 [解析函数示例](/products/cn/web-scraper-api/features/custom-parser/writing-instructions-manually/list-of-functions/function-examples.md) 页面中找到每个函数的使用示例。

## HTML 处理

### `element_text`

* **名称**: `element_text`
* **描述**：从 `html`中提取文本。去除首尾空白字符。
* **参数**：不适用
* **有效输入类型：** `html`
* **预期输出类型：** `字符串`

### `xpath`

* **名称**: `xpath`
* **描述**：在给定输入值上执行一个 XPath 表达式。如果执行未产生结果，则使用数组中的下一个表达式。可在表达式中使用 XSLT 函数。支持 XPath 1.0 版本。支持 XSLT 1.0 版本。
* **参数**:
  * `xpath_expressions`
    * **类型**: `[字符串]`
    * **必填**: `true`
* **有效输入类型：**
  * `html`
* **预期输出类型：**
  * `[字符串]`
  * `[HTML]`
  * `字符串`
  * `浮点数`
  * `布尔值`

### `xpath_one`

* **名称**: `xpath_one`
* **描述**：作用方式与 `xpath`相同，但即使提供的 XPath 选中了多个值，也只返回第一个值。
* **参数**:
  * `xpath_expressions`
    * **类型**: `[字符串]`
    * **必填**: `true`
* **有效输入类型：**
  * `html`
* **预期输出类型：**
  * `字符串`
  * `html`
  * `字符串`
  * `浮点数`
  * `布尔值`

### `css`

* **名称**: `css`
* **描述**：在给定输入值上执行一个 CSS 表达式。如果执行未产生结果，则使用数组中的下一个表达式。 **请注意， `css` 函数的输出始终是一个包含 HTML 元素（包括开始标签和结束标签）的 JSON 数组。如果您想提取元素内容，可以随后执行 `element_text` 函数。**
* **参数**:
  * `css_expressions`
    * **类型**: `[字符串]`
    * **必填**: `true`
* **有效输入类型：**
  * `html`
* **预期输出类型：**
  * `[HTML 元素]`

### `css_one`

* **名称**: `css_one`
* **描述**：作用方式与 `css`，但即使提供的 CSS 表达式选中了多个值，也只返回第一个值。 **请注意， `css_one` 函数的输出始终是一个 HTML 元素（包括开始标签和结束标签）。如果您想提取元素内容，可以随后执行 `element_text` 函数。**
* **参数**:
  * `css_expressions`
    * **类型**: `[字符串]`
    * **必填**: `true`
* **有效输入类型：**
  * `html`
* **预期输出类型：**
  * `html_element`

## 字符串处理

### `amount_from_string`

* **名称**: `amount_from_string`
* **描述**：查找字符串中首次出现的数值，并将其转换为浮点数。
* **参数**：不适用
* **有效输入类型：**
  * `字符串`
* **预期输出类型：**
  * `浮点数`

### `amount_range_from_string`

* **名称**: `amount_range_from_string`
* **描述**：查找字符串中所有出现的数值，并将其转换为浮点数。
* **参数**：不适用
* **有效输入类型：**
  * `字符串`
* **预期输出类型：**
  * `[浮点数]`

### `join`

* **名称**: `join`
* **描述**：将字符串列表合并为一个字符串。合并后的值之间由 `分隔符` 值分隔。
* **参数**:
  * `分隔符`
    * **类型：** `字符串`
    * **必需：** `false`
    * **默认值：** `""`
* **有效输入类型：**
  * `[字符串]`
* **预期输出类型：**
  * `字符串`

### `regex_find_all`

* **名称**: `regex_find_all`
* **描述**：查找所有与给定正则表达式匹配的字符串。
* **参数**:
  * `regex_pattern`
    * **类型：** `字符串`
    * **必需：** `true`
* **有效输入类型：**
  * `字符串`
* **预期输出类型：**
  * `[字符串]`

### `regex_search`

* **名称**: `regex_search`
* **描述**：查找与给定正则表达式匹配的字符串。返回指定的匹配组（默认为 `0`).
* **参数**:
  * `regex_pattern`
    * **类型：** `字符串`
    * **必需：** `true`
  * `group_to_return`
    * **类型：** `整数`
    * **必需：** `false`
    * **默认值：** `0`
* **有效输入类型：**
  * `字符串`
* **预期输出类型：**
  * `字符串`

### `regex_substring`

* **名称**: `regex_substring`
* **描述**：查找与给定正则表达式匹配的字符串。返回指定的匹配组（默认为 `0`).
* **参数**:
  * `regex_pattern`
    * **类型：** `字符串`
    * **必需：** `true`
  * `group_to_return`
    * **类型：** `整数`
    * **必需：** `false`
    * **默认值：** `0`
* **有效输入类型：**
  * `字符串`
* **预期输出类型：**
  * `字符串`

## 常用

### `length`

* **名称**: `length`
* **描述**：获取数组的长度。如果输入的是多维数组，该函数会作用于最内层数组。
* **参数**：不适用
* **有效输入类型：**
  * `[一维数组]`
* **预期输出类型：**
  * `整数`

### `select_nth`

* **名称**: `select_nth`
* **描述**：返回第 n 个数组元素。索引从 0 开始。支持负索引以选择最后一个（`-1`）、倒数第二个（`-2`）等数组项。
* **参数**:
  * `index`
    * **类型：** `整数`
    * **必需：** `true`
* **有效输入类型：**
  * `[任意类型]`
* **预期输出类型：**
  * `任意类型`

### `convert_to_float`

* **名称**: `convert_to_float`
* **描述**：将字符串或整数转换为浮点数。
* **参数**：不适用
* **有效输入类型：**
  * `字符串`
  * `整数`
* **预期输出类型：**
  * `浮点数`

### `convert_to_int`

* **名称**: `convert_to_int`
* **描述**：将字符串或浮点数转换为整数。
* **参数**：不适用
* **有效输入类型：**
  * `字符串`
  * `浮点数`
* **预期输出类型：**
  * `整数`

### `convert_to_str`

* **名称**: `convert_to_str`
* **描述**：将整数或浮点数转换为字符串。
* **参数**：不适用
* **有效输入类型：**
  * `整数`
  * `浮点数`
* **预期输出类型：**
  * `字符串`

## 数学

### `average`

* **名称**: `average`
* **描述**：计算数组中各值的平均值。
* **参数**:
  * `round_precision`
    * **类型：** `整数`
    * **必需：** `false`
* **有效输入类型：**
  * `[整数]`
  * `[浮点数]`
* **预期输出类型：**
  * `浮点数`

### `max`

* **名称**: `max`
* **描述**：查找数组中的最大值。
* **参数**：不适用
* **有效输入类型：**
  * `[浮点数]`
  * `[整数]`
* **预期输出类型：**
  * `浮点数`
  * `整数`

### `min`

* **名称**: `min`
* **描述**：查找数组中的最小值。
* **参数**：不适用
* **有效输入类型：**
  * `[浮点数]`
  * `[整数]`
* **预期输出类型：**
  * `浮点数`
  * `整数`

### `product`

* **名称**: `product`
* **描述**：返回数组中所有值的乘积。
* **参数**：不适用
* **有效输入类型：**
  * `[浮点数]`
  * `[整数]`
* **预期输出类型：**
  * `浮点数`
  * `整数`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/products/cn/web-scraper-api/features/custom-parser/writing-instructions-manually/list-of-functions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
