Get button element dimensions with javascript and perform mouse click.
_script = """
function main(splash)
assert(splash:go(splash.args.url))
local get_dimensions = splash:jsfunc([[
function () {
var rect = document.getElementById('button').getClientRects()[0];
return {"x": rect.left, "y": rect.top}
}
]])
splash:set_viewport_full()
splash:wait(0.1)
local dimensions = get_dimensions()
splash:mouse_click(dimensions.x, dimensions.y)
Wait split second to allow event to propagate.
splash:wait(0.1)
return splash:html()
end
"""
您可以模拟行为,例如滚动或单击,方法是编写JavaScript脚本,并告诉Splash在呈现页面时执行该脚本。在
一个小例子:
您可以定义一个JavaScript函数,该函数选择页面中的元素,然后单击该元素:
(来源:splash doc)
然后,当
^{pr2}$request
时,修改endpoint
,并将其设置为"execute"
,然后将"lua_script": _script
添加到参数中。在您将找到有关splash脚本的所有信息here
相关问题 更多 >
编程相关推荐