신원형

working at linux

......@@ -5,6 +5,23 @@
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha All",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/test"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"<node_internals>/**/*.js"
]
},
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
......
......@@ -40,23 +40,35 @@ ex)
*/
export async function get_schedule(id, pw, target_date) {
login(id, pw).then(async driver => {
load(driver, target_date)
.then(it => {
console.log(it)
logout(driver)
return using_selenium((driver) => {
return login(driver, id, pw)
.then(() => {
return load(driver, target_date)
.then((data) => {
//logout(driver)
console.log(data)
return data
})
})
})
}
export async function login(id, pw) {
export async function using_selenium(next) {
const option = new firefox.Options()
option.setBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
option.addArguments("-headless");
const driver = new selenium.Builder()
.forBrowser('firefox')
.setFirefoxOptions(option)
.build()
next(driver).finally(() => {
driver.quit()
})
}
export async function login(driver, id, pw) {
await driver.get("https://khcanvas.khu.ac.kr/")
const idInput = await driver.findElement(selenium.By.xpath('//*[@id="login_user_id"]'));
......
import fs from 'fs/promises'
import { login, load, logout } from './khcanvas.js';
fs.readFile("asdffdsa.txt").then(it => {
const auth = it.toString().split('|')
login(auth[0], auth[1]).then(async driver => {
load(driver, new Date())
.then(it => {
console.log(it)
logout(driver)
})
}).catch(err => { console.log(err) })
})
\ No newline at end of file
......
......@@ -9,7 +9,7 @@
"version": "1.0.0",
"dependencies": {
"@types/selenium-webdriver": "^4.1.0",
"eslint": "^8.15.0",
"eslint": "^8.16.0",
"mocha": "^10.0.0",
"selenium-webdriver": "^4.1.2"
},
......@@ -18,14 +18,14 @@
}
},
"node_modules/@eslint/eslintrc": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.3.tgz",
"integrity": "sha512-uGo44hIwoLGNyduRpjdEpovcbMdd+Nv7amtmJxnKmI8xj6yd5LncmSwDa5NgX/41lIFJtkjD6YdVfgEzPfJ5UA==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz",
"integrity": "sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==",
"dependencies": {
"ajv": "^6.12.4",
"debug": "^4.3.2",
"espree": "^9.3.2",
"globals": "^13.9.0",
"globals": "^13.15.0",
"ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.0",
......@@ -439,11 +439,11 @@
}
},
"node_modules/eslint": {
"version": "8.15.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.15.0.tgz",
"integrity": "sha512-GG5USZ1jhCu8HJkzGgeK8/+RGnHaNYZGrGDzUtigK3BsGESW/rs2az23XqE0WVwDxy1VRvvjSSGu5nB0Bu+6SA==",
"version": "8.16.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.16.0.tgz",
"integrity": "sha512-MBndsoXY/PeVTDJeWsYj7kLZ5hQpJOfMYLsF6LicLHQWbRDG19lK5jOix4DPl8yY4SUFcE3txy86OzFLWT+yoA==",
"dependencies": {
"@eslint/eslintrc": "^1.2.3",
"@eslint/eslintrc": "^1.3.0",
"@humanwhocodes/config-array": "^0.9.2",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
......@@ -461,7 +461,7 @@
"file-entry-cache": "^6.0.1",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^6.0.1",
"globals": "^13.6.0",
"globals": "^13.15.0",
"ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
......@@ -1623,14 +1623,14 @@
},
"dependencies": {
"@eslint/eslintrc": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.3.tgz",
"integrity": "sha512-uGo44hIwoLGNyduRpjdEpovcbMdd+Nv7amtmJxnKmI8xj6yd5LncmSwDa5NgX/41lIFJtkjD6YdVfgEzPfJ5UA==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz",
"integrity": "sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==",
"requires": {
"ajv": "^6.12.4",
"debug": "^4.3.2",
"espree": "^9.3.2",
"globals": "^13.9.0",
"globals": "^13.15.0",
"ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.0",
......@@ -1943,11 +1943,11 @@
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="
},
"eslint": {
"version": "8.15.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.15.0.tgz",
"integrity": "sha512-GG5USZ1jhCu8HJkzGgeK8/+RGnHaNYZGrGDzUtigK3BsGESW/rs2az23XqE0WVwDxy1VRvvjSSGu5nB0Bu+6SA==",
"version": "8.16.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.16.0.tgz",
"integrity": "sha512-MBndsoXY/PeVTDJeWsYj7kLZ5hQpJOfMYLsF6LicLHQWbRDG19lK5jOix4DPl8yY4SUFcE3txy86OzFLWT+yoA==",
"requires": {
"@eslint/eslintrc": "^1.2.3",
"@eslint/eslintrc": "^1.3.0",
"@humanwhocodes/config-array": "^0.9.2",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
......@@ -1965,7 +1965,7 @@
"file-entry-cache": "^6.0.1",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^6.0.1",
"globals": "^13.6.0",
"globals": "^13.15.0",
"ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
......
......@@ -14,7 +14,7 @@
"license": "",
"dependencies": {
"@types/selenium-webdriver": "^4.1.0",
"eslint": "^8.15.0",
"eslint": "^8.16.0",
"mocha": "^10.0.0",
"selenium-webdriver": "^4.1.2"
},
......
//@ts-check
//https://github.com/gatoona/AWS-Selenium
import * as canvas from '../khcanvas.js'
import * as rd from 'readline'
import { assert } from 'console';
describe('khcanvas', () => {
it('opening selenium', () => {
//this.timeout(1000);
canvas.using_selenium(async (driver) => {
await driver.get("http://khuhub.khu.ac.kr");
await driver.getTitle().then(function (title) {
console.log(title);
});
});
})
});
describe('khcanvas', () => {
it('get schedule', async () => {
const rl = rd.createInterface({
input: process.stdin,
output: process.stdout
})
rl.question('a', async (a) => {
rl.question('b', async (b) => {
await canvas.get_schedule(a, b, new Date())
.then(it => {
console.log(it)
})
.catch(it => {
console.log(it)
throw new Error();
})
})
})
})
});
\ No newline at end of file
......