node js의 request를 활용하여 url호출 시 userAgent를 변경하고 싶을 때 option을 붙여서 사용한다.

간단하게 호출 할 경우에는 options 부분에 그냥 url만 넣으면 된다.


아래 헤더는 크롬의 익스텐션인 Chrome UA Spoofer를 이용하여 직접 url을 호출 해보고

헤더값을 추출


var request = require('request');
var options = {
    url : 'http://bluesid.tistory.com/',
    headers: {
        'User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25'
    }
};

request(options, function(error, response, html){
    if (error) {throw error};

    console.log (html);
});


개발 중 소스를 고치다 보면 재 확인 시 매번 노드를 재 시작 해야 할 경우

귀차니즘이 존재.


해당 귀차니즘을 nodemon으로...


커맨드 창에서 사용해야 하므로 -g 옵션을 붙여서 설치

$ npm install nodemon -g


이후 부턴 $ node app.js 하던 걸

$ nodemon app.js 으로 뼌경만 해주면 끝


비주얼 스투디오 코드에서 디버깅을 위한 명령어

node --debug app.js


디버깅 포트는 5858이 기본


https://code.visualstudio.com/docs/editor/debugging


https://github.com/buglabs/node-xml2json


XML을 JSON으로 변환

node js 라이브러리


node js에서 xml 사용하기


https://www.npmjs.com/package/xml2js


+ Recent posts