V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zhouyin
V2EX  ›  问与答

puppeteer 爬取一个做了反爬的网站 已经返回'content-disposition': 'attachment; filename=xx.zip 但还是无法下载文件

  •  
  •   zhouyin · 5 天前 · 713 次点击
    ```javascript
    {
    'cache-control': 'no-store, no-cache, must-revalidate',
    connection: 'Keep-Alive',
    'content-disposition': 'attachment; filename="xxxx.zip"',
    'content-length': '21147482',
    'content-type': 'application/zip',
    date: 'Sun, 02 Feb 2025 04:09:28 GMT',
    expires: 'Thu, 19 Nov 1981 08:52:00 GMT',
    'keep-alive': 'timeout=5, max=98',
    pragma: 'no-cache',
    server: 'Apache/2.4.52 (Ubuntu)',
    'set-cookie': 'PHPSESSID=94fvcskn745lsq6tb751gnrpov; expires=Sun, 02-Feb-2025 04:39:28 GMT; Max-Age=1800; path=/',
    'x-php-sess-user': 'dddddd'
    }

    ```
    本来能下载的 前几天网站好像升级了
    3 条回复    2025-02-02 13:48:46 +08:00
    zhouyin
        1
    zhouyin  
    OP
       5 天前
    在 win11 上随 node 启动的 chrome 看图
    https://imgur.la/image/imgapp.xF2jF

    puppeteer 是下面这样启动的

    ```javascript

    const puppeteer = require('puppeteer-extra');
    const StealthPlugin = require('puppeteer-extra-plugin-stealth')
    puppeteer.use(StealthPlugin())



    const browser = await puppeteer.launch({
    headless: false,
    args: ['--no-sandbox', '--disable-setuid-sandbox', '-–disable-gpu',
    '-–disable-dev-shm-usage', '-–no-first-run', '-–no-zygote',
    '-–single-process'],
    });
    ```


    package.json 版本:
    ```javascript

    "dependencies": {
    "chrome-har": "^0.7.1",
    "chrome-launcher": "^0.10.5",
    "puppeteer": "^24.1.1",
    "puppeteer-extra": "^3.3.6",
    "puppeteer-extra-plugin-stealth": "^2.11.2"
    }
    ```
    follower
        2
    follower  
       5 天前
    把手动点击下载的响应头也发出来看下?
    zhouyin
        3
    zhouyin  
    OP
       5 天前
    @follower
    已解决 原来是下载目录设置问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5284 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 01:32 · PVG 09:32 · LAX 17:32 · JFK 20:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.