3

我开始使用scrapy with splash,我想知道splash是否可以处理多个窗口和弹出窗口。作为示例,我想使用该 lua 脚本并尝试获取 google 窗口的内容

function main(splash)
  assert(splash:go("http://stackoverflow.com/"))
  assert(splash:runjs("window.open('http://www.google.com');"))
  assert(splash:wait(5))
  return {
    ?
  }
end
4

1 回答 1

2

我发现了一个小技巧,我做了一个

assert(splash:runjs("window.open = function(url) {window.location.replace(url)};")

因此,您不会打开新窗口,而是将您重定向到该链接,但这是一种黑客行为,如果不使用 window.open 打开弹出窗口,它可能无法正常工作

我认为用硒刮擦也可以是一个解决方案,但我想保持我的东西轻量级

于 2016-09-06T15:20:01.327 回答