splash的使用之四execute/run

splash的使用之四execute/run

execute

render.html,render.png,render.jpeg,render.har和render.json涵盖了许多常见用例,但有时他们还不够.此端点允许编写自定义splash scripts.

参数:

lua_source:string:必需
# 浏览器自动脚本,有关信息可以参阅splash scripts tutorial.
timeout:float:可选
# 与render.html的timeout参数相同.
allowed_domains:string:可选
# 与render.html的allowed_domains参数相同.
proxy:string:可选
# 与render.html的proxy参数相同.
filters:string:可选
# 与render.html的filters参数相同.
save_args:json数组或以逗号分隔的字符串:可选
# 与render.html的save_args参数相同.不仅可以保存默认
的splash参数,还可以保存任何其他参数.
load_args:json对象或字符串:可选
# 与render.html的load_args参数相同.不仅可以加载默认
的splash参数,还可以加载任何其他参数.

# 可以传递任何其他参数,所有参数都可以在splash.args表的脚本中找到.

runsplash的使用之四execute/run

该端与execute相同,
但包装在 function main(splash,args) ... end 的lua_source中.

例如,发送以下脚本到execute:
function main(splash, args)
    assert(splash:go(args.url))
    assert(splash:wait(1.0))
    return splash:html()
end

使用run的方法:
assert(splash:go(args.url))
assert(splash:wait(1.0))
return splash:html()
上一篇
下一篇