rrisd-hac-api 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -0
- package/.github/workflows/npm-publish.yml +33 -0
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/index.js +83 -0
- package/package.json +25 -0
- package/test.js +27 -0
package/.gitattributes
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [created]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: 20
|
|
18
|
+
- run: npm ci
|
|
19
|
+
- run: npm test
|
|
20
|
+
|
|
21
|
+
publish-npm:
|
|
22
|
+
needs: build
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: 20
|
|
29
|
+
registry-url: https://registry.npmjs.org/
|
|
30
|
+
- run: npm ci
|
|
31
|
+
- run: npm publish
|
|
32
|
+
env:
|
|
33
|
+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pwR
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# hac api
|
|
2
|
+
|
|
3
|
+
i was bored so uh i made this
|
|
4
|
+
|
|
5
|
+
# usage
|
|
6
|
+
you first need to require it, like so:
|
|
7
|
+
```js
|
|
8
|
+
const hac = require("rrisd-hac-api");
|
|
9
|
+
const api = new hac();
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
after you do that, call this function:
|
|
14
|
+
```js
|
|
15
|
+
await api.login(username, password);
|
|
16
|
+
```
|
|
17
|
+
---
|
|
18
|
+
once thats done, call this:
|
|
19
|
+
```js
|
|
20
|
+
api.getGrades();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
which will return an array that looks like this:
|
|
24
|
+
```json
|
|
25
|
+
[
|
|
26
|
+
{ courseName: 'PE', average: 100 },
|
|
27
|
+
{ courseName: 'Math', average: 86 },
|
|
28
|
+
{ courseName: 'Spanish', average: 93 },
|
|
29
|
+
{ courseName: 'ELA', average: 97 },
|
|
30
|
+
{ courseName: 'Science', average: 92 },
|
|
31
|
+
{ courseName: 'History', average: 90 },
|
|
32
|
+
{ courseName: 'Band', average: 96 }
|
|
33
|
+
]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## it will take a few seconds to fetch, be patient.
|
package/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
const cheerio = require('cheerio');
|
|
3
|
+
const qs = require('qs');
|
|
4
|
+
const { wrapper } = require('axios-cookiejar-support');
|
|
5
|
+
const { CookieJar } = require('tough-cookie');
|
|
6
|
+
|
|
7
|
+
class hac {
|
|
8
|
+
constructor() {
|
|
9
|
+
const jar = new CookieJar();
|
|
10
|
+
this.client = wrapper(axios.create({
|
|
11
|
+
baseURL: 'https://accesscenter.roundrockisd.org/HomeAccess/',
|
|
12
|
+
jar,
|
|
13
|
+
withCredentials: true,
|
|
14
|
+
headers: {
|
|
15
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
16
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
|
17
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async login(username, password) {
|
|
23
|
+
const loginPage = await this.client.get('Account/LogOn?ReturnUrl=%2fhomeaccess');
|
|
24
|
+
const $ = cheerio.load(loginPage.data);
|
|
25
|
+
|
|
26
|
+
const token = $('input[name="__RequestVerificationToken"]').val();
|
|
27
|
+
|
|
28
|
+
if (!token) {
|
|
29
|
+
throw new Error("Could not find RequestVerificationToken. The site layout might have changed.");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const payload = qs.stringify({
|
|
33
|
+
'__RequestVerificationToken': token,
|
|
34
|
+
'SCKTY00328510CustomEnabled': 'False',
|
|
35
|
+
'SCKTY00436568CustomEnabled': 'False',
|
|
36
|
+
'Database': '10',
|
|
37
|
+
'VerificationOption': 'UsernamePassword',
|
|
38
|
+
'LogOnDetails.UserName': username,
|
|
39
|
+
'tempUN': '',
|
|
40
|
+
'tempPW': password,
|
|
41
|
+
'LogOnDetails.Password': password
|
|
42
|
+
}, { format: 'RFC1738' });
|
|
43
|
+
|
|
44
|
+
const response = await this.client.post('Account/LogOn?ReturnUrl=%2fhomeaccess', payload, {
|
|
45
|
+
headers: {
|
|
46
|
+
'Referer': 'https://accesscenter.roundrockisd.org/HomeAccess/Account/LogOn?ReturnUrl=%2fhomeaccess',
|
|
47
|
+
'Origin': 'https://accesscenter.roundrockisd.org'
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (response.data.includes('LogOnDetails.Password')) {
|
|
52
|
+
throw new Error('Login failed: Invalid credentials.');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async getGrades() {
|
|
59
|
+
const { data: html } = await this.client.get('Content/Student/Assignments.aspx');
|
|
60
|
+
const $ = cheerio.load(html);
|
|
61
|
+
const courses = [];
|
|
62
|
+
|
|
63
|
+
$('.AssignmentClass').each((i, element) => {
|
|
64
|
+
const $el = $(element);
|
|
65
|
+
let rawTitle = $el.find('.sg-header-heading').text().trim();
|
|
66
|
+
let cleanTitle = rawTitle.replace(/\s\s+/g, ' ');
|
|
67
|
+
let courseName = cleanTitle.split(' AVG')[0].trim();
|
|
68
|
+
let averageText = $el.find('.sg-header-heading.sg-right').text().trim();
|
|
69
|
+
let average = parseFloat(averageText.replace(/[^\d.]/g, ''));
|
|
70
|
+
|
|
71
|
+
if (courseName) {
|
|
72
|
+
courses.push({
|
|
73
|
+
courseName,
|
|
74
|
+
average: isNaN(average) ? null : average
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return courses;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = hac;
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rrisd-hac-api",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "a scraper based api for round rock isd home access center",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node test.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"rrisd",
|
|
11
|
+
"hac",
|
|
12
|
+
"home-access-center",
|
|
13
|
+
"grades",
|
|
14
|
+
"round-rock-isd"
|
|
15
|
+
],
|
|
16
|
+
"author": "pwR",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"axios": "^1.6.0",
|
|
20
|
+
"axios-cookiejar-support": "^5.0.0",
|
|
21
|
+
"cheerio": "^1.0.0-rc.12",
|
|
22
|
+
"qs": "^6.11.0",
|
|
23
|
+
"tough-cookie": "^4.1.3"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/test.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const HAC = require('./index');
|
|
2
|
+
const readline = require('node:readline/promises');
|
|
3
|
+
const { stdin: input, stdout: output } = require('node:process');
|
|
4
|
+
|
|
5
|
+
const api = new HAC();
|
|
6
|
+
|
|
7
|
+
(async () => {
|
|
8
|
+
const rl = readline.createInterface({ input, output });
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
const username = await rl.question('Username: ');
|
|
12
|
+
const password = await rl.question('Password: ');
|
|
13
|
+
rl.close();
|
|
14
|
+
|
|
15
|
+
await api.login(username, password);
|
|
16
|
+
const grades = await api.getGrades();
|
|
17
|
+
|
|
18
|
+
if (grades.length === 0) {
|
|
19
|
+
console.log('No data returned.');
|
|
20
|
+
} else {
|
|
21
|
+
console.table(grades);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(error.message);
|
|
26
|
+
}
|
|
27
|
+
})();
|