首页 文章

Splash不会呈现页面的所有内容

提问于
浏览
1

我正在使用Splash v2.3.2并且我正在尝试渲染page但它不会渲染所有内容 . 它不会呈现图像或动态加载的内容 .

我正在使用我的http://localhost:8050/脚本:

function main(splash)
  local url = splash.args.url
  assert(splash:go(url))
  assert(splash:wait(10))
  return {
    html = splash:html(),
    png = splash:png(),
    har = splash:har(),
  }
end

这是一个浏览器渲染:
browser rendering

以下是Splash渲染的屏幕截图:
Splash rendering

我试图改变等待时间,并试图允许插件 . 这些都不会起作用 . 我假设动态加载的内容受到限制,但我不确定 . 任何帮助表示赞赏 .

2 回答

  • 3

    问题出在localStorage上 - 站点使用它,但Splash默认使用私有模式,这会取消localStorage . 要解决此问题,请禁用私有模式(请参阅here) . 这个脚本适合我(Splash 3.0):

    function main(splash)
      splash.private_mode_enabled = false
      local url = splash.args.url
      assert(splash:go(url))
      assert(splash:wait(10))
      return {
        html = splash:html(),
        png = splash:png(),
        har = splash:har(),
      }
    end
    

    另见:http://splash.readthedocs.io/en/stable/faq.html#website-is-not-rendered-correctly

  • 1

    我假设你正试图刮掉属性描述文本 . 在您的代码中,您刚刚添加了splash:wait(10),我的建议是您应该尝试并实现等待特定的css元素 . 在你的情况下, span#listingpropertydescription . 您可以编写一个函数来等待这个特定元素,然后返回html页面 .

    Note 您可以在http://localhost:8050/中找到示例等待元素代码

    希望对你有帮助

相关问题