taki

Install
yarn add taki
Usage
const taki = require('taki')
taki({ url: 'https://sao.js.org', wait: 1000 })
.then(html => {
console.log(html)
})
Multiplate URLs
taki({
url: ['https://sao.js.org', 'https://sao.js.org/#/create']
}).then(result => {
})
Choose a browser
Can be eithor jsdom
(default) or chrome
.
When you choose chrome
it will prefer chromium
if it's also installed.
taki({
url,
browser: 'chrome'
})
Manually take snapshot
By default taki will take a snapshot of the URL in a specific timeout (50 by default) when all resource are loaded, if you have control of the website's source code, you can disable that and manually call window.snapshot
:
taki({
url: 'http://my-web.com',
manually: true
})
And in your website's source code:
fetchSomeData().then(data => {
this.setState({ data }, () => {
+ window.snapshot && window.snapshot()
})
})
Wait
Wait for specific timeout or a CSS selector to appera in dom.
taki({
url,
wait: 3000,
wait: '.comments'
})
Resource filter
Only for browser: 'jsom'
By default we fetch all resources in script
tag, but you can control which should be excluded:
const URL = require('url')
const url = 'http://example-website.com'
taki({
url,
resourceFilter(resource) {
return resource.url.host === URL.parse(url).host
}
})
See the resource definition here.
Canvas support
It's supported natively in chrome
, but if you want to use it in jsdom
, please install canvas or canvas-prebuilt alongside taki.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
taki © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).
egoist.moe · GitHub @egoist · Twitter @rem_rin_rin