
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@tsofist/webshot
Advanced tools
Быстрый, а главное эффективный, способ "сфотографировать" веб-страницу.
file:)pdf, png, jpegПод капотом electron
npm i @tsofist/webshot --save --production
import { startupShooter } "webshot";
const myShooter = startupShooter();
/**
* Page from URL to binary Buffer
*/
function shotPageByURLToBinaryBuffer(url: string, format: ShotFormat): Promise<Buffer> {
return myShooter
.then((shooter) => shooter.shotURL(format, url));
}
/**
* Page from URL to local file
*/
function shotPageByURLToFile(url: string, format: ShotFormat, filename: string): Promise<string> {
return myShooter
.then((shooter) => shooter.shotURL(format, url, filename));
}
/**
* Page from URL to stream (e.g. Express.Response)
*/
function shotPageByURLToStream(url: string, format: ShotFormat, destination: NodeJS.WritableStream): Promise<NodeJS.WritableStream> {
return myShooter
.then((shooter) => shooter.shotURL(format, url, destination));
}
И это не все! Можно проделать тоже самое но с html!
import { startupShooter } "webshot";
const myShooter = startupShooter();
/**
* Page as HTML-string to binary Buffer
*/
function shotHTMLToBinaryBuffer(html: string, format: ShotFormat): Promise<Buffer> {
return myShooter
.then((shooter) => shooter.shotHTML(format, url));
}
/**
* Page as HTML-string to local file
*/
function shotHTMLToFile(html: string, format: ShotFormat, filename: string): Promise<string> {
return myShooter
.then((shooter) => shooter.shotHTML(format, url, filename));
}
/**
* Page as HTML-string to stream (e.g. Express.Response)
*/
function shotHTMLToStream(html: string, format: ShotFormat, destination: NodeJS.WritableStream): Promise<NodeJS.WritableStream> {
return myShooter
.then((shooter) => shooter.shotHTML(format, url, destination));
}
Как только вам надоест потребность в конверторе иссякнет, его можно остановить, либо уничтожить вовсе.
// soft
myShooter.shutdown(() => console.log("Shooter is shutted down"));
// hard
myShooter.halt();
Формат можно описывать следующим образом:
// PDF
{
type: "pdf",
marginsType?: 0 // default
|1 // no
|2; // minimum
pageSize?: "Legal"
|"Letter"
|"Tabloid"
|"A3"|"A4"|"A5"
|{ height: number; width: number; };
printBackground?: boolean; // false by default
landscape?: boolean; // false by default
}
// PNG
{
type: "png",
scaleFactor?: number;
size?: "auto"|{ height: number; width: number; };
}
// JPEG
{
type: "jpeg",
quality: number;
size?: "auto"|{ height: number; width: number; };
}
FAQs
A quick and effective way to shoot web pages
We found that @tsofist/webshot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.