# Script

### Script Definition

The script is a JSON. JSON can be parsed in most languages, making it more versatile. Nesting multiple JSONs to achieve continuous operations.

#### Example

```json
 {
	"method": "redirect",
	"url": "https://www.baidu.com/",
	"next": {
		"method": "inputKeyword",
		"xpath": "//*[@id=\"kw\"]",
		"keyword": "和泉雾纱",
		"next": {
			"method": "click",
			"xpath": "//*[@id=\"su\"]"
		}
	}
}
```

Method and its parameters correspond to all [action ](https://wwydev.gitbook.io/crawlist/action#parms-of-action)method names and their parameters

### Use the script

It is more recommended that you use scripts for [pre\_load](https://wwydev.gitbook.io/crawlist/action#what-is-pre_load).

<pre class="language-python"><code class="lang-python"><strong>import crawlist as cl
</strong>
<strong>class MyPager(cl.DynamicNumButtonPager):
</strong>    def pre_load(self, webdriver: WebDriver) -> None:
        script = {
            "method": "redirect",
            "url": "https://www.baidu.com/",
            "next": {
                "method": "inputKeyword",
                "xpath": "//*[@id=\"kw\"]",
                "keyword": "和泉雾纱",
                "next": {
                    "method": "click",
                    "xpath": "//*[@id=\"su\"]"
                }
            }
        }
        cl.Script(script)(webdriver)
</code></pre>

### crawlipt

If you want a richer script, you can use the crawlipt project

```sh
pip install crawlipt
```

{% embed url="<https://github.com/WwwwwyDev/crawlipt>" %}


---

# Agent Instructions: 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:

```
GET https://wwydev.gitbook.io/crawlist/guide/script.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
