Skip to content

davidjuhyung/puppeteer-api

Repository files navigation

Puppeteer Web API

Why do you need a Puppeteer Web API?


To get a screenshot of an HTML page

Request Body Parameters

Parameter Type Required Description Default Value
html string Yes The stringified HTML n/a
width number No The width of screenshot width of body
height number No The height of screenshot height of body
x number No The x position of top-left corner of screenshot 0
y number No The y position of top-left corner of screenshot 0

Response

Buffer

Example

const html = `
  <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
    </head>
    <body>
     Hello
    </body>
    <style>
      body {
        width: 100px;
        height: 50px;
      }
    </style>
  </html>
`
try {
  const res = await axios.post('https://puppeteer-web-api.herokuapp.com/screenshot'. {
    html,
    width: 100,
    height: 50
  })
  
  fs.writeFileSync('tmp.png', Buffer.from(res.data))

} catch (err) {
  console.log({err})
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published