up-如何设置下载位置 [英] puppeteer - how to set download location

查看:79
本文介绍了up-如何设置下载位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够使用puppeteer成功下载文件,但只是将其保存到我的/ Downloads文件夹中。我一直到处逛逛,在api或论坛中找不到任何内容来设置此位置。

I was able to successfully download a file with puppeteer, but it was just saving it to my /Downloads folder. I've been looking around and can't find anything in the api or forums to set this location.

我的下载内容基本上只是转到链接:

My downloads are basically just go going to the link:

await page.goto(url);


推荐答案

这是最新设置下载路径的方法puppeteer v0.13。

This is how you can set the download path in latest puppeteer v0.13.

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

此行为是实验性的,可能会在以后删除,修改或更改。

The behaviour is experimental, it might be removed, modified, or changed later.

Pst,您可以尝试此处,后果自负:)。

Pst, you can try more tricks listed here, on your own risk :).

这篇关于up-如何设置下载位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆