4.2. $('#goodsList").empty() 비우면, 이제까지 저장했던 데이터가 사라진다. 모든 상품 목록은 api/goods에 붙는다. /goods = req query, query string 안에 category라는 것을 변수로 받는다
4.3. folder → refresh → cart 생성, cart 정보 가져오는 api 없음 (post 로만 생성)
4.6. 프론트 먼저 구성하고 CRUD → 배포 → Design
크롤링 개념
- node.js로도 크롤링 가능 / 엑셀 파일 생성/분석 등 다양한 업무자동화
- JS 만으로도 가능한 업무자동화
- 업무 자동화는 흔히 파이썬으로 하는 것으로 알려져 있지만, JS 만으로도 웹사이트의 데이터를 가져오는 크롤링 및 엑셀 파일을 만들거나 분석/가공 엑셀 업무자동화
- 데이터를 긁어오는 역할
- 방대한 자료가 들어있는 특정 웹사이트의 데이터를 한번에 다 가져오고 싶을 때, 크롤링 기술을 사용해야 한다.
- 기존에 공부한 HTML 태그 문법 지식을 통해 웹사이트의 구조 파악
- 가지고 보고 싶은 데이터 HTML 영역 특정
- 데이터 BringIn/out 크롤링 라이브러리 사용
- nodejs에 필요한 것 (크롤링)
-
axios, cheerio, iconv-lite 설치
-
ol tag → li tag → p tag a/img tag
-
.copy → p tag 이면서 copy라는 클래스를 가진것을 찾게 된다
→ 띄어쓰기 하면 child로 들어감
- function 정리
- slice (0, -1): 맨 뒤의 원래 문자 삭제
- replace(/(,)/g"") : 문자 중간에 콤마 있으면, 빈 문자열, 즉 없애는 코드
- goodsId : unique quote of number
- shift + Enter key : move to next line
- SSH 보안접속이 상대적으로 뛰어남
- terminal linux 방법 (window)
- ssh - i (key-pair address)
- ubuntu @ IPV4 address
- yes
- linux use
- node.js 설치 명령어
- i = insert
- esc = end
- :wq = save and exit
- :ql = not save and exit
- Filezilla
- setting: 맨 위 → new site → protocol: SFTP
- Teminal 실행 방법
- pm2 start index.js
- pm2 ls → 에러 나올시 에러 해결하기 그리고 다시 한번 pm2 log로 확인
- pm2 delete 0
- pm2 ls
- pm2 start index.js
- pm2 ls
- pm2 log
- how to kill ${port} in terminal
- sudo lsof -t -i : {port}
- sudo kill error#, 바로 위 해당번호
- pm2 ls
- 서버 끄고 다시 재실행
- watching disable → watching able 정상
- 고쳐지지 않았을 때, pm2 delete 0, pm2 kill 실행 → 그 후, pm2 ls
- pm2 start index.js → watch로 고쳐짐
- watch → enabled 로 changed
- question
- terminal
- #security → # 지우고 security 로 변경
- test in RoBo3T
- failed to connect to 13.125.0.31:27017
- test save
-
내가 원격으로 AWS를 몽고디비로 조작할 수 있다, but, aws코드랑 mongoDB연결은 별개다.
-
git bash mkdir → 새로운 폴더 생성
-
terminal
- node modules public routers routes, schemas, views 불러오기
- index.js, package-lock.json, package.json 넣어주기
- ls 통해서 파일 확인
- sudo -s, npm install → pm2
- pm2 → pm2 설치확인용도
- pm2 start index.js
- pm2 log
- ctrl + c →program out (turn off function)
- pm2 ls 다시 확인
- status -> online 으로 되어있으면 성공
- url instance address (IPV4 형태)
- 13.125.0.31/home
- 접근금지
- pm2 ls 확인했더니 status 가 online인데 서버로 돌렸을때 안되었다.
- solution: aws → 80 port → 3000 port → success
-
EJS → HTML 생성하기 위해 필요함, 백엔드 ajax가 있어야 html 가능
-
express → node라는 환경안에 장치
-
terminal에서 npm install
-
eventually, HTML/EJS 같은 기능 포함
-
res.render = ejs 파일을 렌더링 해주는 역할
-
res.send = 메세지를 보내겠다는 의미
-
ejs = html 이니 해당 url을 불러 올 경우, 해당 페이지를 띄워져야 하므로, render 맞다
-
wireframe structure
- 목록조회 /list
- 쓰기페이지 /write
- 상세조회페이지 /inquire
- 수정페이지 /modify
-
새로 알게 된 module 설치
- npm install nodemon
- npm i
- nom install -g nodemon