Casperjs 사용하여 내용 긁어온뒤 excel로 다운받기

<전체설치방법>
https://blog.seotory.com/post/2016/10/start-headless-project-in-window

phantomjs는 npm으로 간단히 설치했고 casperjs도 설치, python도 설치하고 환경변수 삽입

 

npm install -g casperjs 이렇게 설치하니 됨
http://blog.saltfactory.net/web-scraping-using-with-casperjs/

 

var casper = require(‘casper’).create();
casper.start(‘http://casperjs.org/&#8217;);

casper.then(function() {
this.echo(‘First Page: ‘ + this.getTitle());
});

casper.thenOpen(‘http://phantomjs.org&#8217;, function() {
this.echo(‘Second Page: ‘ + this.getTitle());
});

casper.run();

 

위와 같이 가져옴
http://casperjs.org/

 

casper.fetchText(“h4.head em”) <- 데이터 찾는 법

 

<데이터 추가하기>
Use append mode a instead of [over]write mode w in the fs.write call.

var fs = require(‘fs’);
try {
fs.write(“file.txt”, “Hello World”, ‘a’);
fs.write(“file.txt”, “Hello World”, ‘a’);
} catch(e) {
console.log(e);
}
a로 바꿔주면 추가가 된다.

 

< html 테이블을 excel로 옮기기>
http://serpiko.tistory.com/581

 

< jquery.excelexport로 excel 다운받기>
http://marsland.tistory.com/416

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s