0

I'm scraping website which has a very annoying link (<a> HTML tag) - it opens the small pop-up form on click and after submitting it, opens new browser tab (and switches focus to it) with URL that I need, and also redirects old tab to another page.

Successful submitting of the pop-up form was easy, but I don't know how to get URL of this new tab.

And as the documentation says, Splash can work only with one tab, so is it impossible to do that?

Illia Ananich
  • 353
  • 4
  • 16

1 Answers1

0

As Splash's developer comments on this GitHub issue this feature is not implemented.

But I posted my solution to this problem on the same issue. Example:

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
Illia Ananich
  • 353
  • 4
  • 16