
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
phantomjs-capture
Advanced tools
Simple and lightweight HTML to image capture and html using Node and PhantomJS.
npm install phantomjs-capture
The API exposes a single function 'capture'. Using this function, you can input a multitude of settings, which are further specified below:
var capture = require('phantomjs-capture');
capture(options, function(err, result) {
console.log(result.fullPNGPath); // PNG PATH
console.log(result.filePNGName); // PNG File Name
console.log(result.fileHTMLPath); // HTML PATH
console.log(result.fileHTMLName); // HTML File Name
});
You must install phantom from http://phantomjs.org/download.html
Calling capture() requires an options object, which includes the following definitions:
{
'url': 'http://ju.taobao.com', // 需要截图的页面的URL,必须的参数; Remote URL, Required.
'dir': '.', // 输出文件目录; Directory
'output': 'xxx.png', // 输出文件名; File name
'size': '1920x768', // 需要截图的页面的宽度x高度, eg: -s 800x600; Captrue width x height, eg: -size 800x600
'screenTimer': 1000, // 滚屏的时间,如果该时间太短,可能造成一些异步加载的数据未返回时,页面出现空白等,单位:ms。 eg: -t 10000; Screen Timer
'domHook': 'ju-footer' // DOM上的ID节点,表示此元素出现后将停止截屏,如 <div id="footer"></div>, -hook footer; DOM Hook
}
test.js
var capture = require('phantomjs-capture');
capture({
dir: '.',
output: 'xx.png',
url: 'http://ju.taobao.com',
size: '1920x800',
domHook: 'ju-footer',
screenTimer: 6000
}, function(err, results){
console.log(arguments);
});
You must install phantom from http://phantomjs.org/download.html
Usage: capture [options]
Options:
-h, --help output usage information
-V, --version output the version number
-d, --dir [string] 输出文件目录。eg: -d ./
-o, --output [string] 输出文件名。eg: -o xxx.png
-u, --url [string] 需要截图的页面的URL。eg: -u http://ju.taobao.com
-s, --size [string] 需要截图的页面的宽度x高度, eg: -s 800x600
-dh, --dom-hook [string] DOM上的ID节点,表示此元素出现后将停止截屏,如 <div id="footer"></div>, -hook footer
-phantomPath, --phantomPath [string] phantomjs的路径, -phantomPath /usr/local/bin/phantomjs
-t, --screen-timer [integer] 滚屏的时间,如果该时间太短,可能造成一些异步加载的数据未返回时,页面出现空白等,单位:ms。 eg: -t 10000
capture --dir . --output xx --url http://ju.taobao.com -size 1920x800 -dom-hook ju-footer -screen-timer 6000 -phantomPath /usr/local/bin/phantomjs
or
capture -d . -o xx -u http://ju.taobao.com -s 1920x800 -dh ju-footer -s 6000
FAQs
Captures Screenshots using Phantom.js
The npm package phantomjs-capture receives a total of 5 weekly downloads. As such, phantomjs-capture popularity was classified as not popular.
We found that phantomjs-capture 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
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.