0

我正在抓取具有非常烦人的链接(<a>HTML 标记)的网站 - 它会在单击时打开小弹出表单,并在提交后打开带有我需要的 URL 的新浏览器选项卡(并将焦点切换到它),并且将旧标签重定向到另一个页面。

成功提交弹出表单很容易,但我不知道如何获取这个新标签的 URL。

正如文档所说,Splash 只能使用一个选项卡,所以不可能做到这一点吗?

4

1 回答 1

0

由于 Splash 的开发人员对此 GitHub 问题的评论,此功能未实现。

但是我在同一个问题上发布了对这个问题的解决方案。例子:

function main(splash, args)

  assert(splash:go(args.url))  -- execute JS code below only after loading the page

  splash:runjs("var newTabURL")
  splash:runjs("newTabURL = null")  -- sometimes JS can't find variable without this line
  splash:runjs("window.open = function(url){newTabURL = url}")

  -- actions which open the new tab

  local new_tab_url  = splash:evaljs("newTabURL")

  -- other actions
end
于 2018-03-23T09:04:02.773 回答