IT Information/최신 기술 동향

PhantomJS, CasterJS 설치 및 사용

계발꿈나무 2013. 11. 1. 19:28
반응형



PhantomJS: is a headless WebKit with JavaScript API. (WebKit:Chrome, safari 등 브라우저 없이 JS를 사용할 수 있음)

 

CasperJS: is a navigation scripting & testing utility that runs on top/alongside of PhantomJS.

The Api of Phantom JS is based on JavaScript: how would you execute code in a browser? Web sites JavaScript code is sandboxed, so that it does not interact with the main tool. Nothing is rendered to the screen like Selenium, we use the command-line.


PhantomJS

공식사이트

http://phantomjs.org/

설치, 사용설명

http://nodeqa.com/nodejs_ref/86

http://mobicon.tistory.com/237

예제

https://github.com/ariya/phantomjs/tree/master/examples

----설치요약

Guidouil's answer put me on the right track. I had to add one additional symlink to /usr/bin/, and I did direct symlinks for all 3 - see below.

I'm installing on Ubuntu server Natty Narwhal.

This is exactly what I did.


cd /usr/local/share

wget http://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2

tar -xjf phantomjs-1.9.1-linux-x86_64.tar.bz2

sudo ln -s /usr/local/share/phantomjs-1.9.1-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs

sudo ln -s /usr/local/share/phantomjs-1.9.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs

sudo ln -s /usr/local/share/phantomjs-1.9.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs




=>And finally when I do

phantomjs -v

I get 1.9.1


* when you get error like "error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory"

=> apt-get install libfontconfig1


Thanks Guidouil. Perfect timing. I've been working on this for a whole day. Sorry, I don't have enough reputation yet to vote you up, yet.

If anyone sees any problems with what I've done, please let me know.

----------- 사용

phantomjs rasterize.js url imgname.jpg


CasperJS

공식사이트

https://github.com/n1k0/casperjs

설치, 사용설명

http://nodeqa.com/nodejs_ref/69



반응형