cemalgnlts / owlser

Puppeteer playground.
https://deta.space/discovery/@cemalgnlts/owlser
11 stars 1 forks source link

Save An Image to Drive #1

Closed xeust closed 1 year ago

xeust commented 1 year ago

@cemalgnlts this is super cool!

In the example snippet, there is an upload to Drive feature:

await page.goto("https://deta.space")

// Capture a screenshot and get page title.
const ss = await page.screenshot()
const title = await page.title()

// Let's upload the screenshot to Drive.
upload("ss.png", ss)

// Return the page title as a log record.
return `Page title: ${title}`

It runs successfully, but I can't seem to find the image in Drive. I assume this isn't yet implemented?

cemalgnlts commented 1 year ago

Thanks,

I made a mistake, the upload function works async, it is necessary to wait for the completion of loading with await, otherwise the operation is canceled when the function ends.

await page.goto("https://deta.space")

// Capture a screenshot and get page title.
const ss = await page.screenshot()
const title = await page.title()

// Let's upload the screenshot to Drive.
- upload("ss.png", ss)
+ await upload("ss.png", ss)

// Return the page title as a log record.
return `Page title: ${title}`