Skip to content

PhantomJS

PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

한마디로 화면없이 Webkit engine(QT) 을 사용하여 웹사이트 컨트롤 할 수 있는 모듈입니다.
Scriptable Headless WebKit 보통 이와 같이 설명하는데, Headless 라는 말은 머리가 없는 이라는 의미가 아니라 화면이 없는 의미입니다.

How to install

$ suto apt-get install phantomjs

시스템에 한글 폰트가 설치되어 있지 않은 경우:

$ sudo apt-get install fonts-unfonts-core
$ sudo apt-get install fonts-unfonts-extra

Screenshot

// screenshot.js
var page = require('webpage').create();
page.open('http://www.daum.net', function () {
    page.render('daum.png');
    phantom.exit();
});

이후 아래와 같이 실행하면 된다.

phantomjs screenshot.js

See also

Favorite site

References


  1. Nodejs_and_Phantomjs_-_web_scraping.pdf