반응형

명령어 프롬프트(cmd)에서

 

npm init
npm install cheerio-httpcli


인스톨을 한 후에

 

아래와 같은 예제 입력후 파일 저장 (ex. download.js)

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var client = require('cheerio-httpcli');
 
var url = "http://nickoo.tistory.com";
var param = {};
 
client.fetch(url, param, function(err, $, res){
  if(err){console.log("error:", err); return;}
 
  var body = $.html();
  console.log(body);
 
});
 
 
 
cs

 

 

이렇게 한 후에 node download.js 를 명령어 프롬프트에 입력하면 HTML문서를 화면에 출력합니다.

 

 

반응형

'프로그래밍 > Node.js' 카테고리의 다른 글

CasperJS 설치  (0) 2017.04.07
PhantomJS 설치  (0) 2017.04.07
XML/RSS 파싱에 cheerio-httpcli 이용  (0) 2017.04.06
HTML 파일에서 링크 추출  (0) 2017.03.27
윈도우에서 'Node.js'와 'NPM'을 설치하기  (0) 2017.03.25

+ Recent posts