问题描述
我正在尝试使用 javascript 和 lua 拖动网站中显示的验证码滑块,如下所示。我无法运行脚本。我认为问题是我的 lua 代码的 javascript 部分。特别是 getBoundingClientRect()
没有正确执行。我怎样才能运行这段代码。
我的测试-
function main(splash,args)
--I am trying to drag the captcha slider present in the site https://world.taobao.com/markets/all/sea/register
splash:set_custom_headers({
["Referer"]= "https://world.taobao.com/",["User-Agent"]= "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/88.0.4324.182 Safari/537.36",["Origin"]= "https://reg.taobao.com",})
assert(splash:go(args.url))
assert(splash:wait(5.0))
local get_slider_dimensions = splash:jsfunc([[
function () {
var rect = document.querySelectorAll("div#nc_1__scale_text span")[0].getBoundingClientRect();
return {"x": rect.left,"y": rect.top,"width":rect.width}
}
]])
splash:set_viewport_full()
splash:wait(0.1)
local slider_dimensions = get_slider_dimensions()
splash:wait(0.1)
splash:mouse_press(slider_dimensions.x,slider_dimensions.y)
splash:mouse_release(slider_dimensions.x+slider_dimensions.width,slider_dimensions.y)
return splash:png()
end
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)