var path = 'output1.txt';

var save = 'output2.txt';

var fs = require('fs');



fs.stat(path, function(err, stats) {

if (stats.isFile(path)) {

        console.log('쿠키파일 존재');

    }

});

   

블로그 이미지

칩사마코더

,

쿠키 파일로 저장

크롤링 2016. 9. 22. 21:15

//쿠키 저장

casper.start(url,function(){

console.log("크롤링 시작");

//cookiesManager.saveCookies();

this.echo(this.evaluate(function() {

        return document.cookie;

    }));

});



//파일로 저장

    fs = require('fs');

        fs.writeFile('helloworld.txt', result, function(err) {

            if (err)

                return console.log(err);

            console.log('Hello World > helloworld.txt');

        });

'크롤링' 카테고리의 다른 글

캐스퍼 url 접속 여부 테스트  (0) 2017.03.13
원하는 패턴 문자열 뽑기  (0) 2017.02.07
fetchText 와 getHTML 차이  (0) 2016.10.29
캐스퍼 함수들 정리  (0) 2016.10.20
블로그 이미지

칩사마코더

,

   child.stdout.on("data", function(data) {

        i= i + 1;

        console.log(i + "번째");

        result += data;

       var str = data;

       console.log(`${str.length} characters, ` +

            `${Buffer.byteLength(str, 'utf8')} bytes`);

    });



console.log(`${str.length} characters, ` +`${Buffer.byteLength(str, 'utf8')} bytes`);

'node js' 카테고리의 다른 글

node.js 애플리케이션을 쉽고 빠르게 실행/종료하기  (0) 2016.10.20
casperjs 쿠키 저장 읽어오기  (0) 2016.09.23
파일 존재 여부 확인  (0) 2016.09.23
spawn 자식프로세스 종료  (0) 2016.09.22
PHP nodejs ajax 연동  (0) 2016.08.26
블로그 이미지

칩사마코더

,