.Install cheerio module- Install Cheerio from npm npm i cheerio .Using cheerio 달러 환율의 일별 시세를 크롤링 해보려고 한다. 12345678910111213141516171819202122232425const request = require("request");const cheerio = require("cheerio"); scrapingResult = { 'date': '', 'the_basic_rate': '', 'buy': '', 'sell': ''} function getData() { request("https://finance.naver.com/marketindex/exchangeDailyQuote.nhn", function (e..
.Install JSON Web Token from npm - 웹표준 (RFC 7519) 으로서 두 개체에서 JSON 객체를 사용하여 가볍고 자가수용적인 (self-contained) 방식으로 정보를 안전성 있게 전달 (링크에서 자세한 설명을 볼 수 있었다)- install jsonwebtoken npm i jsonwebtoken - 여기서 jsonwebtoken을 decoding 할 수 있다. .Login 과정 1. 로그인- 로그인 페이지에서 로그인을 하게 되면 login.ejs 를 호출하게 된다.1234567/*Server.js*/ app.get('/login', function(req, res){ res.render('login');})Colored by Color Scriptercs login.e..
.Install Express Framework- Install Express from npm npm i express - Node.JS 를 위한 가장 인기있는 웹 어플리케이션 프레임워크- 웹 페이지를 위한 서버 및 웹 기반 어플리케이션 개발에 사용 .Using Express Framework - expressServer.js12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849const express = require('express')const path = require('path'); // 기본 라이브러리의 path const app = express() //////////////////////..
.Install mySQL module from npm- mySQL module 설치 npm i mysql .mySQL 연동 123456789101112131415161718var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : '', password : '', database : 'fintech'}); connection.connect(); var query = 'select * from fintech.user'connection.query(query, function (error, results, fields) { if (error) throw error; console.log('..
.NPM - NPM(Nodejs package manager)은 모듈 공유 관리를 위한 플랫폼 .NPM 초기화 - npm 을 활용하기 위해 npm init 으로 초기 세팅 필요 - npm init 작업이 끝나면 package.json 이라는 파일이 생성되는데, 이 파일은 모듈 의존성을 포함 .모듈 서칭 - NPM 홈페이지에서 사용할 모듈 검색(https://www.npmjs.com/) .request 모듈 테스트 - 사라질..? 모듈이라서 request를 검색하면 나오진 않는다.(링크에서 확인)- module page에 들어가면 친절하게 install 방법도 알려준다.- 터미널에 npm i request를 입력하여 모듈 설치 (npm install request과 동일) 아래와 같이 설치해보자. 모듈을 ..
.Node.js http 클래스를 활용한 기본 서버 구성 123456789var http = require("http"); http.createServer(function (req, res) { var body = "hello Server"; res.setHeader('Content-Type', 'text/html; charset=utf-8'); res.end("This is My Server~~~!"+body+"")}).listen(3000); console.log('server is Started'); cs line 1) http 모듈을 require()로 불러온다.line 4) body에 넣을 textline 5) response의 Header를 설정line 7) 3000번 port로 서버 대기