You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Splash无法完整渲染页面求助:配置调整无效

解决Splash无法完整渲染CloudFront防护页面的方案

问题根源判断

CloudFront的X-Cache Error就是核心问题——该CDN的反爬机制识别出Splash请求的非浏览器特征,直接返回了缓存的不完整页面或拦截请求,导致核心内容div未加载渲染。

针对性解决步骤

  • 配置完整浏览器请求头
    不要仅替换User-Agent,需模拟真实浏览器的全套请求头,包括Accept、Accept-Language、Referer等。示例配置:

    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
        'Accept-Language': 'en-US,en;q=0.5',
        'Accept-Encoding': 'gzip, deflate, br',
        'Referer': 'https://www.finishers.com/',
        'Connection': 'keep-alive',
        'Upgrade-Insecure-Requests': '1'
    }
    

    将上述headers传入Splash的render.html或自定义Lua脚本中。

  • 延迟渲染并等待目标元素
    动态内容需等待JS执行完成,同时CloudFront会通过加载时长识别爬虫。可设置wait参数(如5秒),或用Lua脚本等待核心div出现:

    function main(splash, args)
        splash:set_user_agent(args.ua)
        splash:set_custom_headers(args.headers)
        splash:go(args.url)
        -- 替换为目标页面核心div的实际选择器
        splash:wait_for_selector('.core-content-div')
        return splash:html()
    end
    
  • 更换高匿有效代理
    确保使用的是高匿代理(避免透明代理暴露真实IP),且代理IP未被CloudFront拉黑。可先用代理直接访问目标页面,若X-Cache仍显示Error,说明代理无效,更换代理源。

  • 模拟用户交互行为
    添加鼠标移动、页面滚动等动作,让请求更接近真实用户:

    function main(splash, args)
        splash:go(args.url)
        splash:mouse_move(100, 100)
        splash:scroll_position(0, 500)
        splash:wait(2)
        return splash:html()
    end
    
  • 检查Splash启动参数
    确认未启用--disable-images、--disable-javascript等限制页面加载的参数,部分页面会通过资源加载状态校验请求合法性。

补充排查

若以上方法无效,用浏览器开发者工具对比Splash请求与正常请求的所有细节(Cookie、TLS版本、请求顺序等),CloudFront可能会校验这些细微特征。

内容的提问来源于stack exchange,提问作者Ivan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 19:40:03