首页 > 解决方案 > Scrapy Splash 结果为 504

问题描述

我正在尝试在一个特定酒店的页面上获取未来 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。但是如果你想看更多完整的代码在这里:-)

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

标签: pythonweb-scrapingluascrapyscrapy-splash

解决方案


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


推荐阅读