-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Headless downloads #100
Comments
@Nitemaeric try this. const page = await browser.newPage("https://google.com");
const celestial = page.unsafelyGetCelestialBindings();
await celestial.Browser.setDownloadBehavior({ behavior: "allow", downloadPath: "./downloads"}); |
Sorry for the slow response, I've just gotten round to testing this out. This worked great! One thing comes to mind though, is there a way to |
AS far as i can tell, not natively within the browser / astral. But we did have a similar issue and found a way around it. Helper functions: const getFolderFileCount = (folderPath: string) => {
let count = 0;
for (const file of Deno.readDirSync(folderPath)) {
count++;
}
return count;
}
const waitForBool = async (callback: Function, interval: number = 1000) : Promise<boolean> => {
if (await callback()) return true;
await new Promise((resolve) => setTimeout(resolve, interval));
return await waitForBool(callback, interval);
} Check for new files in download folder before and after the download action is triggered. const numberOfFiles = getFolderFileCount(storage);
//do action to begin download
await waitForBool(async () => {
return getFolderFileCount(storage) > numberOfFiles;
}) This won't account for edge cases like files taking too long to download or downloads that stop but it does cover a successful download pretty well. |
I'm not sure if it's currently possible with Astral, but how would one allow headless downloads?
https://issues.chromium.org/issues/41304545#comment40
It seems that
Browser.setDownloadBehavior
needs to be configured with{ behaviour: "allow", downloadPath: path }
via CDP?The text was updated successfully, but these errors were encountered: