V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
liwenbest
V2EX  ›  Python

求助: pyppeteer 是如何修改默认的浏览器下载路径的吗

  •  
  •   liwenbest · 2019-09-21 11:51:02 +08:00 · 3170 次点击
    这是一个创建于 1676 天前的主题,其中的信息可能已经有所发展或是发生改变。
    有个任务需要用到 pyppeteer 模拟点击网页的图片下载按钮,但是只能下载到浏览器的默认下载路径中,本人知道 selenium 可以修改默认下载路径,但是 pyppeteer 目前还没有找到方法修改,不知道各位大佬有没有方法可以修改到
    2 条回复    2019-09-23 09:11:58 +08:00
    littlespider89
        1
    littlespider89  
       2019-09-21 17:33:03 +08:00   ❤️ 1
    pyppeteer 其实是封装了一下 puppeteer, 所以问题应该是 puppeteer 如何修改下载路径
    搜索一下 puppeteer download location,第一个就是 stackoverflow 上的答案,做个搬运工

    await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: './myAwesomeDownloadFolder'});

    看了下说这个 API 是实验性的,可能后面版本会改变去掉,至于现在能不能用了,需要去试一下
    另外 pyppeteer 也不是支持所有的 puppeteer API,在 pyppeteer 能不能用,也需要去试一下啦
    liwenbest
        2
    liwenbest  
    OP
       2019-09-23 09:11:58 +08:00
    非常感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5374 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:42 · PVG 11:42 · LAX 20:42 · JFK 23:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.