lua中的splash在scrapy splash项目中如何修复代码?

我有一个链接(https://www.psychologytoday.com/us/therapists/35801),我想要提交一个联系表单。我知道必须使用第三方服务,因为有一个验证码,但我似乎无法加载脚本。我一直收到表错误而不是按钮点击

我已经执行了一个for循环并进行了鼠标单击,但它不起作用。我使用的选择器是"div.result-btn-email button",在Chrome Dev工具中可以工作

function main(splash, args)

  local function submit_forms()
    local btns = splash:select_all('div.result-btn-email button')
    if #btns == 0 then
      error('no elements found')
    end
    for _, btn in ipairs(btns) do
      print(btn, 'found button')
      splash:wait(1)
      btn:mouse_click()
      print(btn, ' found buttn')
    end
  end

  assert(splash:go(args.url))
  assert(splash:wait(0.5))
  submit_forms()

  return {
    html = splash:html(),
    png = splash:png(),
    har = splash:har(),
  }
end

我知道这是不完整的代码,但它仍然无法工作。我一直收到一个错误:

{
    "type": "ScriptError",
    "info": {
        "type": "LUA_ERROR",
        "message": "Lua error: [string \"function main(splash, args)\r...\"]:11: JsError({'js_error': \"TypeError: undefined is not an object (evaluating 'rect.left')\", 'type': 'JS_ERROR', 'message': 'JS error: \"TypeError: undefined is not an object (evaluating \\'rect.left\\')\"', 'js_error_message': \"undefined is not an object (evaluating 'rect.left')\", 'js_error_type': 'TypeError'},)",
        "line_number": 11,
        "error": "JsError({'js_error': \"TypeError: undefined is not an object (evaluating 'rect.left')\", 'type': 'JS_ERROR', 'message': 'JS error: \"TypeError: undefined is not an object (evaluating \\'rect.left\\')\"', 'js_error_message': \"undefined is not an object (evaluating 'rect.left')\", 'js_error_type': 'TypeError'},)",
        "source": "[string \"function main(splash, args)\r...\"]"
    },
    "error": 400,
    "description": "执行Lua脚本时发生错误"
}

我是一个Lua的新手,希望得到一些很好的帮助和资源来学习Lua

点赞