【问题标题】:Scrapy Splash results in 504Scrapy Splash 结果为 504
【发布时间】:2019-05-31 05:16:00
【问题描述】:

我正在尝试从一家特定酒店的页面上获取未来 28 天的价格。我怀疑我被阻止了,但我不太确定。

我得到了一些结果,但不是全部。我什至尝试过使用各种用户代理,download_delay 为 30,启用 httpcahce 等。

这是我的 lua 脚本

    function main(splash, args)
      splash.private_mode_enabled = false
      splash.js_enabled = true
      splash.images_enabled = false
      assert(splash:go(args.url))       
      function wait_for(splash, condition)
        while not condition() do
            splash:wait(20.0)
      end
      end

      wait_for(splash, function()
        return splash:evaljs("document.querySelector('ul.availability-table-revamp') != null")
      end)

      assert(splash:wait(30.0))
      splash:set_viewport_full()
      return {
        html = splash:html(),
      }
    end

我正在抓取的页面是[这里][1]。

我如何确定是该页面阻止了我?酒店页面上没有政策 - 但(当然)引擎的主页上有政策......

我当然有更多的代码要展示,但我猜唯一能解决这个问题的就是 lua。但是如果你想看更多完整的代码是here :-)

当然希望你比我聪明(不过我想我已经知道答案了)。

【问题讨论】:

    标签: python web-scraping lua scrapy scrapy-splash


    【解决方案1】:

    有时网络会阻止用户ip,尝试使用不同的proxy servers,因为它可以通过我的系统访问。

    【讨论】:

    • 嗯。我意识到这个项目可能不需要启动——只要延迟时间足够长。所以我完全关闭了splash - 然后所有页面都被完美地刮掉了。我觉得这有点奇怪。那么我的 Splash 安装/脚本可能有什么问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-23
    • 2018-01-08
    • 2021-12-26
    • 2020-05-04
    相关资源
    最近更新 更多