programming/node.js
[nodejs] github 커밋 카운터 프로그램
LeeBorn
2019. 11. 27. 00:00
반응형

nodejs로 만든 깃허브 사이트의 커밋 내역을 세는 프로그램.
홈 화면의 잔디밭을 참고한다.
오늘 날짜에 count를 세서 프로그램에 출력한다.
아래 프로그램을 실행하려면 npm으로 cheerio, request, date-utils을 설치해야 한다.
그리고 실행할 때 주소를 넣어야 한다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require('cheerio'); | |
const request = require('request'); | |
const date = require('date-utils'); | |
const target = process.argv[2]; | |
const today = new Date().toFormat("YYYY-MM-DD"); | |
request(target, function(error, response, body){ | |
var test = cheerio.load(body); | |
test('[data-date=' + today +']').each(function(){ | |
const commit = test(this).data("count"); | |
if( commit > 0){ | |
console.log("commit : " + commit); | |
}else{ | |
console.log("no commit :) "); | |
} | |
}) | |
}); |
반응형