{"id":13447889,"url":"https://github.com/b4dnewz/webpage-capture","last_synced_at":"2025-05-04T13:30:53.843Z","repository":{"id":89287977,"uuid":"104526916","full_name":"b4dnewz/webpage-capture","owner":"b4dnewz","description":":camera: Capture the web using headless browser with many options","archived":false,"fork":false,"pushed_at":"2019-05-13T06:45:44.000Z","size":910,"stargazers_count":7,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T20:11:52.592Z","etag":null,"topics":["automation","puppeteer","screenshot","screenshot-utility","webpage-capture"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b4dnewz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-22T23:31:44.000Z","updated_at":"2024-02-12T21:30:26.000Z","dependencies_parsed_at":"2023-04-01T05:34:48.193Z","dependency_job_id":null,"html_url":"https://github.com/b4dnewz/webpage-capture","commit_stats":{"total_commits":96,"total_committers":1,"mean_commits":96.0,"dds":0.0,"last_synced_commit":"a7d550d41724850abcaa9f83ffd19767e0747368"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4dnewz%2Fwebpage-capture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4dnewz%2Fwebpage-capture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4dnewz%2Fwebpage-capture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4dnewz%2Fwebpage-capture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b4dnewz","download_url":"https://codeload.github.com/b4dnewz/webpage-capture/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252341195,"owners_count":21732468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","puppeteer","screenshot","screenshot-utility","webpage-capture"],"created_at":"2024-07-31T05:01:29.593Z","updated_at":"2025-05-04T13:30:53.496Z","avatar_url":"https://github.com/b4dnewz.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# webpage-capture\n\n\u003e Capture the web in many ways using headless chrome\n\n[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]\n\nThis program is an overlay of [puppeteer](https://github.com/GoogleChrome/puppeteer) which is designed to allow the easy extraction of single or multiple pages or sections, in multiple formats and in the fastest way possible.\n\n\n## Installation as module\n\nIf you want to use it inside your scripts, save and install it in your project dependencies.\n\n```\nnpm install --save webpage-capture\n```\n\nOnce it has done you can import **webpage-capture** in your scripts and start using it, refer to the [usage](#usage) section.\n\n## Installation as CLI\n\nYou can also use it from the command line using the [cli module](https://github.com/b4dnewz/webpage-capture-cli), installing it globally:\n\n```\nnpm install -g webpage-capture-cli\n```\n\nThan you can start playing around with __webcapture__ command and with the options using the built-in help typing: `--help`\n\n---\n\n## Usage\n\nFirst you have to import __webpage-capture__ and initializire a new capturer with default or custom options.\n\n```js\nimport WebCapture from 'webpage-capture'\nconst capturer = new WebCapture()\n\n(async () =\u003e {\n\n  // Single input\n  await capturer.capture('https://google.it')\n\n  // Multiple inputs\n  const res = await capturer.capture([\n    'https://github.com/b4dnewz',\n    'https://github.com/b4dnewz/webpage-capture'\n  ])\n  console.log(res);\n\n})().catch(console.log)\n    .then(capturer.close())\n```\n\nDon't forget to __close__ the capturer once you have done, otherwise the headless browser instance will not disconnect correctly.\n\n### Instance Options\n\nThe constructor can also take options to set default values for all the subsequent captures:\n\n```js\nconst capturer = new WebCapture({\n  // default options\n})\n```\n\n#### outputDir\n\nType: `String`  \nDefault value: `process.cwd()`\n\nSpecify a custom directory where place the captured files.\n\n#### timeout\n\nType: `Number`  \nDefault value: `30000`\n\nSpecify the default page timeout to load a page (in ms).\n\n#### headers\n\nType: `Object`  \n\nSet the headers to be used during all the requests.\n\n#### viewport\n\nType: `String, Object`  \n\nSet the default viewport that is used when not specified.\n\n#### debug\n\nType: `Boolean`  \nDefault value: `false`\n\nRun the script in __headfull__ mode with a delay of 1 second so you can see what is doing.\n\n#### launchArgs\n\nType: `Array`  \nDefault value: `[]`\n\nCustom launch arguments to be passed to Chromium instance, if you are a linux user\nand you are experiencing some issues, you may want to [disable sandbox](https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#setting-up-chrome-linux-sandbox) or setup differently.\n\n---\n\n## Methods\n\n### file(input, outputFilePath, [options])\n\nCapture a screnshot of the given `input` and save it to the given `outputFilePath`.\n\nReturns a `Promise\u003cvoid\u003e` that resolves when the screenshot is written.\n\n### buffer(input, [options])\n\nCapture a screnshot of the given `input`.\n\nReturns a `Promise\u003cBuffer\u003e` with the screenshot as binary.\n\n### base64(input, [options])\n\nCapture a screnshot of the given `input`.\n\nReturns a `Promise\u003cstring\u003e` with the screenshot as [Base64](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding).\n\n### capture(inputs, [options])\n\nCapture one or multiple `input` using the given options.\nFor a complete list of options see below.\n\nReturns a `Promise\u003cvoid\u003e` that resolves when the screenshot is written.\n\n---\n\n## Capture Options\n\n#### type\n\nType: `String`  \nDefault value: `png`  \nPossible values: `png, jpeg, pdf, html, buffer, base64`  \n\nSelect the capture output type.\n\n#### timeout\n\nType: `Number`  \n\nThe timeout to use when capturing input.\n\n#### headers\n\nType: `Object`  \n\nAn object of headers to use when capturing input.\n\n```js\nawait capturer.capture('https://github.com/b4dnewz/webpage-capture', {\n  headers: {\n    'x-powered-by': 'webpage-capture'\n  }\n})\n```\n\n#### waitFor\n\nType: `Number`  \n\nWait for the specified time before capturing the page. (in milliseconds)\n\n#### waitUntil\n\nType: `String`  \n\nWait until the selector is visible into page.\n\n#### fullPage\n\nType: `Boolean`  \n\nCapture the full scrollable page, not just the visible viewport.\n\n#### scripts\n\nType: `String[]`  \n\nInject scripts into the page.\n\n```js\nawait capturer.capture('https://github.com/b4dnewz/webpage-capture', {\n  scripts: [\n    'http://example.com/some/remote/file.js',\n    './local-file.js',\n    'document.body.style.backgroundColor = \"hotpink\";'\n  ]\n})\n```\n\n#### styles\n\nType: `String[]`  \n\nInject styles into the page.\n\n```js\nawait capturer.capture('https://github.com/b4dnewz/webpage-capture', {\n  styles: [\n    'http://example.com/some/remote/file.css',\n    './local-file.css',\n    'body { background-color: \"hotpink\"; }'\n  ]\n})\n```\n\n#### viewport\n\nType: `String, String[]`  \n\nOne or more viewport to capture.\n\n```js\n// capture single viewport\nawait capturer.capture('https://github.com/b4dnewz/webpage-capture', {\n  viewport: 'nexus-5'\n})\n\n// capture multiple viewports\nawait capturer.capture('https://github.com/b4dnewz/webpage-capture', {\n  viewport: ['nexus-5', 'nexus-10']\n})\n```\n\n#### viewportCategory\n\nType: `String`  \nDefault value: `false`\n\nCapture all viewports that match the category name.\n\n```js\n// capture all mobile viewports\nawait capturer.capture('https://github.com/b4dnewz/webpage-capture', {\n  viewportCategory: 'mobile'\n})\n```\n\n---\n\n## License\n\nMIT © [Filippo Conti](LICENSE)\n\n## Contributing\n\n1.  Create an issue and describe your idea\n2.  Fork the project (\u003chttps://github.com/b4dnewz/webpage-capture/fork\u003e)\n3.  Create your feature branch (`git checkout -b my-new-feature`)\n4.  Commit your changes (`git commit -am 'Add some feature'`)\n5.  Write some tests and run it (`npm run test'`)\n6.  Publish the branch (`git push origin my-new-feature`)\n7.  Create a new Pull Request\n\n\n[npm-image]: https://badge.fury.io/js/webpage-capture.svg\n\n[npm-url]: https://npmjs.org/package/webpage-capture\n\n[travis-image]: https://travis-ci.org/b4dnewz/webpage-capture.svg?branch=master\n\n[travis-url]: https://travis-ci.org/b4dnewz/webpage-capture\n\n[daviddm-image]: https://david-dm.org/b4dnewz/webpage-capture.svg?theme=shields.io\n\n[daviddm-url]: https://david-dm.org/b4dnewz/webpage-capture\n\n[coveralls-image]: https://coveralls.io/repos/b4dnewz/webpage-capture/badge.svg\n\n[coveralls-url]: https://coveralls.io/r/b4dnewz/webpage-capture\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb4dnewz%2Fwebpage-capture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb4dnewz%2Fwebpage-capture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb4dnewz%2Fwebpage-capture/lists"}