Showing
9 changed files
with
110 additions
and
9 deletions
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | ## Configuration | 5 | ## Configuration |
6 | 6 | ||
7 | - Front-End : React | 7 | - Front-End : React |
8 | -- Back-End : Node.js | 8 | +- Back-End : Express |
9 | - Storage : LocalForage | 9 | - Storage : LocalForage |
10 | - Crawl : Puppeteer | 10 | - Crawl : Puppeteer |
11 | 11 | ||
... | @@ -21,6 +21,14 @@ npm install | ... | @@ -21,6 +21,14 @@ npm install |
21 | 21 | ||
22 | ### Run | 22 | ### Run |
23 | 23 | ||
24 | +#### Terminal 1 | ||
25 | + | ||
24 | ```sh | 26 | ```sh |
25 | npm start | 27 | npm start |
26 | ``` | 28 | ``` |
29 | + | ||
30 | +#### Terminal 2 | ||
31 | + | ||
32 | +```sh | ||
33 | +npm run server | ||
34 | +``` | ... | ... |
... | @@ -11,7 +11,9 @@ | ... | @@ -11,7 +11,9 @@ |
11 | "@testing-library/jest-dom": "^5.16.4", | 11 | "@testing-library/jest-dom": "^5.16.4", |
12 | "@testing-library/react": "^13.2.0", | 12 | "@testing-library/react": "^13.2.0", |
13 | "@testing-library/user-event": "^13.5.0", | 13 | "@testing-library/user-event": "^13.5.0", |
14 | + "axios": "^0.27.2", | ||
14 | "express": "^4.18.1", | 15 | "express": "^4.18.1", |
16 | + "fs": "^0.0.1-security", | ||
15 | "localforage": "^1.10.0", | 17 | "localforage": "^1.10.0", |
16 | "puppeteer": "^14.1.1", | 18 | "puppeteer": "^14.1.1", |
17 | "react": "^18.1.0", | 19 | "react": "^18.1.0", |
... | @@ -4534,6 +4536,28 @@ | ... | @@ -4534,6 +4536,28 @@ |
4534 | "node": ">=12" | 4536 | "node": ">=12" |
4535 | } | 4537 | } |
4536 | }, | 4538 | }, |
4539 | + "node_modules/axios": { | ||
4540 | + "version": "0.27.2", | ||
4541 | + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", | ||
4542 | + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", | ||
4543 | + "dependencies": { | ||
4544 | + "follow-redirects": "^1.14.9", | ||
4545 | + "form-data": "^4.0.0" | ||
4546 | + } | ||
4547 | + }, | ||
4548 | + "node_modules/axios/node_modules/form-data": { | ||
4549 | + "version": "4.0.0", | ||
4550 | + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", | ||
4551 | + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", | ||
4552 | + "dependencies": { | ||
4553 | + "asynckit": "^0.4.0", | ||
4554 | + "combined-stream": "^1.0.8", | ||
4555 | + "mime-types": "^2.1.12" | ||
4556 | + }, | ||
4557 | + "engines": { | ||
4558 | + "node": ">= 6" | ||
4559 | + } | ||
4560 | + }, | ||
4537 | "node_modules/axobject-query": { | 4561 | "node_modules/axobject-query": { |
4538 | "version": "2.2.0", | 4562 | "version": "2.2.0", |
4539 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", | 4563 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", |
... | @@ -7865,6 +7889,11 @@ | ... | @@ -7865,6 +7889,11 @@ |
7865 | "node": ">= 0.6" | 7889 | "node": ">= 0.6" |
7866 | } | 7890 | } |
7867 | }, | 7891 | }, |
7892 | + "node_modules/fs": { | ||
7893 | + "version": "0.0.1-security", | ||
7894 | + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", | ||
7895 | + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" | ||
7896 | + }, | ||
7868 | "node_modules/fs-constants": { | 7897 | "node_modules/fs-constants": { |
7869 | "version": "1.0.0", | 7898 | "version": "1.0.0", |
7870 | "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", | 7899 | "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", |
... | @@ -19801,6 +19830,27 @@ | ... | @@ -19801,6 +19830,27 @@ |
19801 | "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.2.tgz", | 19830 | "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.2.tgz", |
19802 | "integrity": "sha512-LVAaGp/wkkgYJcjmHsoKx4juT1aQvJyPcW09MLCjVTh3V2cc6PnyempiLMNH5iMdfIX/zdbjUx2KDjMLCTdPeA==" | 19831 | "integrity": "sha512-LVAaGp/wkkgYJcjmHsoKx4juT1aQvJyPcW09MLCjVTh3V2cc6PnyempiLMNH5iMdfIX/zdbjUx2KDjMLCTdPeA==" |
19803 | }, | 19832 | }, |
19833 | + "axios": { | ||
19834 | + "version": "0.27.2", | ||
19835 | + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", | ||
19836 | + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", | ||
19837 | + "requires": { | ||
19838 | + "follow-redirects": "^1.14.9", | ||
19839 | + "form-data": "^4.0.0" | ||
19840 | + }, | ||
19841 | + "dependencies": { | ||
19842 | + "form-data": { | ||
19843 | + "version": "4.0.0", | ||
19844 | + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", | ||
19845 | + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", | ||
19846 | + "requires": { | ||
19847 | + "asynckit": "^0.4.0", | ||
19848 | + "combined-stream": "^1.0.8", | ||
19849 | + "mime-types": "^2.1.12" | ||
19850 | + } | ||
19851 | + } | ||
19852 | + } | ||
19853 | + }, | ||
19804 | "axobject-query": { | 19854 | "axobject-query": { |
19805 | "version": "2.2.0", | 19855 | "version": "2.2.0", |
19806 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", | 19856 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", |
... | @@ -22224,6 +22274,11 @@ | ... | @@ -22224,6 +22274,11 @@ |
22224 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", | 22274 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", |
22225 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" | 22275 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" |
22226 | }, | 22276 | }, |
22277 | + "fs": { | ||
22278 | + "version": "0.0.1-security", | ||
22279 | + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", | ||
22280 | + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" | ||
22281 | + }, | ||
22227 | "fs-constants": { | 22282 | "fs-constants": { |
22228 | "version": "1.0.0", | 22283 | "version": "1.0.0", |
22229 | "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", | 22284 | "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", | ... | ... |
... | @@ -6,7 +6,9 @@ | ... | @@ -6,7 +6,9 @@ |
6 | "@testing-library/jest-dom": "^5.16.4", | 6 | "@testing-library/jest-dom": "^5.16.4", |
7 | "@testing-library/react": "^13.2.0", | 7 | "@testing-library/react": "^13.2.0", |
8 | "@testing-library/user-event": "^13.5.0", | 8 | "@testing-library/user-event": "^13.5.0", |
9 | + "axios": "^0.27.2", | ||
9 | "express": "^4.18.1", | 10 | "express": "^4.18.1", |
11 | + "fs": "^0.0.1-security", | ||
10 | "localforage": "^1.10.0", | 12 | "localforage": "^1.10.0", |
11 | "puppeteer": "^14.1.1", | 13 | "puppeteer": "^14.1.1", |
12 | "react": "^18.1.0", | 14 | "react": "^18.1.0", |
... | @@ -19,7 +21,8 @@ | ... | @@ -19,7 +21,8 @@ |
19 | "start": "react-scripts start", | 21 | "start": "react-scripts start", |
20 | "build": "react-scripts build", | 22 | "build": "react-scripts build", |
21 | "test": "react-scripts test", | 23 | "test": "react-scripts test", |
22 | - "eject": "react-scripts eject" | 24 | + "eject": "react-scripts eject", |
25 | + "server": "nodemon server/server.js" | ||
23 | }, | 26 | }, |
24 | "eslintConfig": { | 27 | "eslintConfig": { |
25 | "extends": [ | 28 | "extends": [ |
... | @@ -38,5 +41,6 @@ | ... | @@ -38,5 +41,6 @@ |
38 | "last 1 firefox version", | 41 | "last 1 firefox version", |
39 | "last 1 safari version" | 42 | "last 1 safari version" |
40 | ] | 43 | ] |
41 | - } | 44 | + }, |
45 | + "type": "module" | ||
42 | } | 46 | } | ... | ... |
1 | -const puppeteer = require("puppeteer"); | 1 | +import puppeteer from "puppeteer"; |
2 | //use puppeteer | 2 | //use puppeteer |
3 | 3 | ||
4 | function setTimeoutPromise(ms) { | 4 | function setTimeoutPromise(ms) { |
... | @@ -110,6 +110,6 @@ try { | ... | @@ -110,6 +110,6 @@ try { |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | -login("2021105253", "qtw@@04271"); | 113 | +// login("2021105253", "qtw@@04271"); |
114 | 114 | ||
115 | export { login }; | 115 | export { login }; | ... | ... |
1 | //The prototype | 1 | //The prototype |
2 | -// const puppeteer = require("puppeteer"); | 2 | +// import puppeteer from "puppeteer"; |
3 | // const crawler = async() => { | 3 | // const crawler = async() => { |
4 | // try{ | 4 | // try{ |
5 | // const browser = await puppeteer.launch({headless: false, args:['--window-size=1920,1080']}); | 5 | // const browser = await puppeteer.launch({headless: false, args:['--window-size=1920,1080']}); | ... | ... |
1 | -const puppeteer = require("puppeteer"); | 1 | +import puppeteer from "puppeteer"; |
2 | //use puppeteer | 2 | //use puppeteer |
3 | 3 | ||
4 | function setTimeoutPromise(ms) { | 4 | function setTimeoutPromise(ms) { |
... | @@ -110,4 +110,4 @@ try { | ... | @@ -110,4 +110,4 @@ try { |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | -login("2021105253", "qtw@@04271"); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
113 | +// login("2021105253", "qtw@@04271"); | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
server/server.js
0 → 100644
1 | +import express from "express"; | ||
2 | +import { login } from "./libs/E_Campus.js"; | ||
3 | +import fs from "fs"; | ||
4 | + | ||
5 | +const app = express(); | ||
6 | +const router = express.Router(); | ||
7 | + | ||
8 | +router.get("/", (req, res) => { | ||
9 | + res.header("Access-Control-Allow-Origin", "http://localhost:3000"); | ||
10 | + res.send({ test: "Hi" }); | ||
11 | + console.log("listened /"); | ||
12 | +}); | ||
13 | + | ||
14 | +app.use("/", router); | ||
15 | + | ||
16 | +fs.readFile("server/login.pvdata", "utf8", (err, data) => { | ||
17 | + if (err) { | ||
18 | + console.error(err); | ||
19 | + console.log("server/login.pvdata에 ID\\nPW를 작성"); | ||
20 | + return; | ||
21 | + } | ||
22 | + login(...data.split("\r\n")); | ||
23 | + | ||
24 | + app.listen(3001, function () { | ||
25 | + console.log("listening on 3001"); | ||
26 | + }); | ||
27 | +}); |
1 | +import axios from "axios"; | ||
1 | import { useState } from "react"; | 2 | import { useState } from "react"; |
2 | import { useNavigate } from "react-router-dom"; | 3 | import { useNavigate } from "react-router-dom"; |
3 | //import { login } from "../libs/E_Campus"; | 4 | //import { login } from "../libs/E_Campus"; |
... | @@ -32,9 +33,13 @@ const Debug = () => { | ... | @@ -32,9 +33,13 @@ const Debug = () => { |
32 | case "login": | 33 | case "login": |
33 | //result = login(state.input1, state.input2); | 34 | //result = login(state.input1, state.input2); |
34 | break; | 35 | break; |
36 | + case "server": | ||
37 | + axios | ||
38 | + .get("http://localhost:3001/") | ||
39 | + .then((res) => setState({ ...state, output: res.data.test })); | ||
40 | + return; | ||
35 | default: | 41 | default: |
36 | } | 42 | } |
37 | - console.log(result); | ||
38 | setState({ ...state, output: result }); | 43 | setState({ ...state, output: result }); |
39 | }; | 44 | }; |
40 | 45 | ||
... | @@ -57,6 +62,7 @@ const Debug = () => { | ... | @@ -57,6 +62,7 @@ const Debug = () => { |
57 | <select name="type" value={state.type} onChange={handleChangeState}> | 62 | <select name="type" value={state.type} onChange={handleChangeState}> |
58 | <option value={"initSubjects"}>initSubjects</option> | 63 | <option value={"initSubjects"}>initSubjects</option> |
59 | <option value={"login"}>login</option> | 64 | <option value={"login"}>login</option> |
65 | + <option value={"server"}>server</option> | ||
60 | </select> | 66 | </select> |
61 | </div> | 67 | </div> |
62 | 68 | ... | ... |
-
Please register or login to post a comment