{"id":13508680,"url":"https://github.com/egoist/taki","last_synced_at":"2025-04-09T13:09:51.190Z","repository":{"id":45275052,"uuid":"98186059","full_name":"egoist/taki","owner":"egoist","description":"Take a snapshot of any website.","archived":false,"fork":false,"pushed_at":"2022-04-03T08:37:33.000Z","size":583,"stargazers_count":143,"open_issues_count":2,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T11:06:41.722Z","etag":null,"topics":["crawler","prerender","snapshot"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/egoist.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}},"created_at":"2017-07-24T12:00:57.000Z","updated_at":"2025-01-20T19:15:52.000Z","dependencies_parsed_at":"2022-09-14T05:02:03.768Z","dependency_job_id":null,"html_url":"https://github.com/egoist/taki","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Ftaki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Ftaki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Ftaki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Ftaki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egoist","download_url":"https://codeload.github.com/egoist/taki/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045245,"owners_count":21038554,"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":["crawler","prerender","snapshot"],"created_at":"2024-08-01T02:00:56.917Z","updated_at":"2025-04-09T13:09:51.176Z","avatar_url":"https://github.com/egoist.png","language":"TypeScript","funding_links":[],"categories":["JavaScript","TypeScript"],"sub_categories":[],"readme":"# taki\n\n[![NPM version](https://img.shields.io/npm/v/taki.svg?style=flat)](https://npmjs.com/package/taki) [![NPM downloads](https://img.shields.io/npm/dm/taki.svg?style=flat)](https://npmjs.com/package/taki) [![CircleCI](https://circleci.com/gh/egoist/taki/tree/master.svg?style=shield)](https://circleci.com/gh/egoist/taki/tree/master) [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026style=flat)](https://github.com/egoist/donate)\n\n## Install\n\n```bash\nnpm i taki\n```\n\nBuilt on the top of Google's [Puppeteer](https://github.com/GoogleChrome/puppeteer), for a jsdom/chromy version please visit [here](https://github.com/egoist/taki/tree/jsdom-chromy).\n\n## Usage\n\n```js\nconst { request } = require('taki')\n\n// Prerender this page to static HTML\n// Wait for 1s since this page renders remote markdown file\nrequest({ url: 'https://sao.js.org', wait: 1000 }).then((html) =\u003e {\n  // serialized html string of target url\n  console.log(html)\n})\n```\n\n**NOTE**: You need to call `cleanup` when you no longer use `request`:\n\n```js\nimport { cleanup } from 'taki'\n\n// After fetching..\ncleanup()\n```\n\n### Custom html selector\n\nBy default it returns the html for the entire document, but you can specify a selector to get the html for a specific element.\n\n```js\nconst { request } = require('taki')\n\nrequest({ url: 'https://example.com', htmlSelector: '.some-element' }).then(\n  (html) =\u003e {\n    console.log(html)\n  }\n)\n```\n\n### Manually take snapshot\n\nBy default **taki** will take a snapshot of the URL when all resources are loaded, if you have control of the website's source code, you can disable that and manually call `window.snapshot`:\n\n```js\nrequest({\n  url: 'http://my-web.com',\n  manually: true,\n})\n```\n\nAnd in your website's source code:\n\n```diff\nfetchSomeData().then(data =\u003e {\n  this.setState({ data }, () =\u003e {\n+    window.snapshot \u0026\u0026 window.snapshot()\n  })\n})\n```\n\nAlternatively, choose your own method to invoke when your app is ready to return HTML:\n\n```js\nrequest({\n  url: 'http://my-web.com',\n  manually: 'iamready',\n})\n```\n\nThen call `window.iamready()` instead of `window.snapshot()` in your app.\n\n### Wait\n\nWait for specific timeout or a CSS selector to appear in dom.\n\n```js\nrequest({\n  url,\n  // Wait for 3000 ms\n  wait: 3000,\n  // Or wait for \u003cdiv class=\"comments\"\u003e\u003c/div\u003e to appear\n  wait: '.comments',\n})\n```\n\nThis option will be ignored if [manually](#manually-take-snapshot) is set.\n\n### Minify\n\nMinify HTML.\n\n```js\nrequest({\n  url,\n  minify: true,\n})\n```\n\n### Filter resource\n\nWe always abort network requests to following types of resource: `stylesheet` `image` `media` `font` since they're not required to render the page. In addtion, you can use `resourceFilter` option to abort specfic type of resource:\n\n```js\nrequest({\n  url,\n  /**\n   * @param {Object} context\n   * @param {string} context.type - Resource type\n   * @see {@link https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#requestresourcetype}\n   * @param {string} context.url - Resource URL\n   * @see {@link https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#requesturl}\n   * @returns {boolean} Whether to load this resource\n   */\n  resourceFilter({ type, url }) {\n    // Return true to load the resource, false otherwise.\n  },\n})\n```\n\nYou can also use `blockCrossOrigin: true` shortcut to block all cross-origin requests.\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Author\n\n**taki** © [egoist](https://github.com/egoist), Released under the [MIT](./LICENSE) License.\u003cbr\u003e\nAuthored and maintained by egoist with help from contributors ([list](https://github.com/egoist/taki/contributors)).\n\n\u003e [Website](https://egoist.sh) · GitHub [@egoist](https://github.com/egoist) · Twitter [@\\_egoistlily](https://twitter.com/_egoistlily)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Ftaki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegoist%2Ftaki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Ftaki/lists"}