{"id":19857689,"url":"https://github.com/markmur/screenshots-cli","last_synced_at":"2025-02-28T21:47:42.145Z","repository":{"id":65474417,"uuid":"183960434","full_name":"markmur/screenshots-cli","owner":"markmur","description":"Take screenshots for a list of URLs and viewports with puppeteer","archived":false,"fork":false,"pushed_at":"2019-04-30T14:29:27.000Z","size":102,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T01:06:52.621Z","etag":null,"topics":["cli","node","puppeteer","puppeteer-screenshot","screenshot"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markmur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-28T21:24:09.000Z","updated_at":"2022-08-15T22:04:43.000Z","dependencies_parsed_at":"2023-01-25T12:45:45.313Z","dependency_job_id":null,"html_url":"https://github.com/markmur/screenshots-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmur%2Fscreenshots-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmur%2Fscreenshots-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmur%2Fscreenshots-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmur%2Fscreenshots-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markmur","download_url":"https://codeload.github.com/markmur/screenshots-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241246273,"owners_count":19933324,"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":["cli","node","puppeteer","puppeteer-screenshot","screenshot"],"created_at":"2024-11-12T14:19:27.173Z","updated_at":"2025-02-28T21:47:42.115Z","avatar_url":"https://github.com/markmur.png","language":"JavaScript","readme":"# Screenshots\n\nUse puppeteer to take screenshots of a list of URLs for multiple viewports\n\n## Installation\n\n```sh\nyarn add --global screenshots-cli\n```\n\n## CLI Usage\n\n```\n\n  Take screenshots for a list of URLs and viewports\n\n  Usage\n    $ screenshots\n\n  Options\n    --version          Output version\n    --urls             List of comma-separated URLs to visit. (Must include protocol)\n    --viewports        List of comma-separated viewport dimensions to take screenshots.\n                          Specify both width and height like: 1440x768,768x768\n                          OR only specify the width to capture the entire page.\n                          You can use a combination of both.\n\n    --outputDir, -o    Screenshots directory name. Defaults to $pwd/screenshots\n    --emptyDir, -rm    Empty the output directory\n\n  Authentication Options\n    --loginUrl         URL to authenticate with username/password\n    --username, -u     Auth username\n    --password, -p     Auth password\n\n  Examples\n    $ screenshots \\\n        --urls=https://mysite.com \\\n        --viewports=1440x768,768,480,320\n\n```\n\n## Programmatic Usage\n\n```js\nconst path = require('path')\nconst screenshots = require('screenshots-cli')\n\nscreenshots({\n  urls: ['https://mysite.com/login'],\n  viewports: [\n    [1440, 768], // [width, height] - height is optional\n  ],\n  outputDir: path.join(process.cwd(), 'screenshots'), // default\n})\n  .then()\n  .catch()\n```\n\n### Usage with auth\n\n```js\nconst path = require('path')\nconst screenshots = require('screenshots-cli')\n\nscreenshots({\n  urls: ['https://mysite.com'],\n  loginUrl: 'https://mysite.com/login',\n  username: process.env.USERNAME,\n  password: process.env.PASSWORD,\n})\n  .then()\n  .catch()\n```\n\n### Customising login form selectors\n\n```js\nconst path = require('path')\nconst screenshots = require('screenshots-cli')\n\nscreenshots({\n  urls: ['https://mysite.com/myaccount'],\n  loginUrl: 'https://mysite.com/login',\n  username: process.env.USERNAME,\n  password: process.env.PASSWORD,\n  selectors: {\n    username: 'input[type=\"username\"]',\n    password: 'input[type=\"password\"]',\n    submit: 'input[type=\"submit\"]',\n  },\n})\n  .then(results =\u003e {\n    // Returns array of screenshot objects\n    // See below for results type definition\n  })\n  .catch()\n```\n\n### Results schema\n\n```ts\n[\n  {\n    filename: String,\n    createdAt: Date,\n    uri: Base64\n  },\n  ...\n]\n```\n\n### Options\n\n| Option    | Type      | Required | Default                                                                                          | Description                              |\n| --------- | --------- | -------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------- |\n| urls      | `Array`   | Yes      |                                                                                                  | Array of URLs to visit                   |\n| viewports | `Array`   |          | `[[1440], [768], [425], [320]]`                                                                  | Viewport dimensions to take for each URL |\n| outputDir | `String`  |          | `path.join(process.cwd(), 'screenshots')`                                                        | Directory to write screenshots           |\n| emptyDir  | `Boolean` |          | `false`                                                                                          | Empty the output directory               |\n| loginUrl  | `String`  |          |                                                                                                  | URL to authenticate                      |\n| username  | `String`  |          |                                                                                                  | Auth username                            |\n| password  | `String`  |          |                                                                                                  | Auth password                            |\n| selectors | `Object`  |          | `{ username: 'input[type=\"email\"]', password: 'input[type=\"password\"]', submit: 'form button' }` | HTMLElement selectors for login form     |\n\n## Running locally\n\n### Unauthenticated routes\n\n```sh\nyarn start --urls=https://mysite.com\n```\n\n### Authenticated routes\n\n\u003e You will be prompted for your username and password. The password will be\n\u003e hidden\n\n```sh\nyarn start:auth --urls=https://mysite.com/myaccount\n```\n\n## Diffing two images\n\nMake sure you have `imagemagick` installed locally:\n\n```sh\nbrew install imagemagick\n```\n\nCompare images:\n\n```sh\ncompare screenshots/one.png screenshots/two.png [-highlight-color blue] -compose src diff.png\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkmur%2Fscreenshots-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkmur%2Fscreenshots-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkmur%2Fscreenshots-cli/lists"}