Script
本章介绍脚本的基本使用。脚本使用json格式定义,在各种语言中,你都可以很方便将它反序列化。
转换方式
import crawlipt as cpt
# 在编写阶段可以使用python内置字典类型进行编写
script = {
"method": "redirect",
"url": "https://www.baidu.com/",
"next": {
"method": "input", # 方法名
"xpath": "//*[@id=\"kw\"]", # 方法对应参数
"text": "百度贴吧", # 方法对应参数
"next": { # 下一个要执行的脚本
"method": "click",
"xpath": "//*[@id=\"su\"]"
}
}
}
# 转换为了一个json字符串,可以将它存储在物理介质中
script_json = cpt.Script.generate_json(script) 执行脚本
脚本初始化参数介绍
参数名
类型
介绍
脚本执行器参数介绍
参数名
类型
介绍
通过列表step方式编写脚本
最后更新于