首页 文章

如何使用Splash处理新的标签页?

提问于
浏览
0

我正在抓取一个非常恼人的链接网站( <a> HTML标签) - 它会在点击时打开小弹出窗体,提交后,打开新的浏览器标签(并将焦点切换到它),并带有我需要的URL,以及还将旧标签重定向到另一个页面 .

成功提交弹出窗口很容易,但我不知道如何获取此新选项卡的URL .

正如文档所说,Splash只能使用一个标签,所以不可能这样做吗?

1 回答

  • 0

    作为Splash的开发者commentsthis GitHub issue上,此功能未实现 .

    但是我在同一个问题上发布了这个问题my solution . 例:

    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
    

相关问题