-
-
Save uyjulian/6152949de9ea069bf5773612eb1c05be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--password form: https://no.client.renweb.com/pw/index.cfm | |
--form data: DistrictCode=no&username=fuck&password=kuso&UserType=PARENTSWEB-STUDENT&login=Login | |
--can be compressed | |
--full curl: curl 'https://no.client.renweb.com/pw/index.cfm' -H 'Cookie: CFID=kkk; CFTOKEN=sss; LB-Persist=nr; _gat=1; _ga=bah' -H 'Origin: https://no.client.renweb.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8,es;q=0.6,ja;q=0.4' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: https://no.client.renweb.com/pw/index.cfm' -H 'Connection: keep-alive' --data 'DistrictCode=no&username=fuck&password=kuso&UserType=PARENTSWEB-STUDENT&login=Login' --compressed | |
--important cookies to keep: CFID; CFTOKEN; LB-Persist | |
--no cookie/expired? 302'd back to https://no.client.renweb.com/pw/ | |
--Homework list (monthly) (full): https://no.client.renweb.com/pw/school/calendar-print.cfm?filter=Homework&studentid=&view=list&month=3&year=2016&day=20&range=month | |
--Gtko link: https://no.client.renweb.com/pw/?LogOut=1 | |
--Grade book progress report (aka per class/quarter grade): https://no.client.renweb.com/RenWeb/Reports/Gradebook/GradeBookProgressReport-PW.cfm?District=no&StudentID=idgaf&ClassID=noid&TermID=4&SchoolCode=no&Sessionid=no&ReportHash=no&hashval=nope | |
--all args are on https://no.client.renweb.com/pw/student/grades.cfm: | |
-- <input type="hidden" name="District" value="no" /> | |
-- <input type="hidden" name="ReportType" value="Gradebook" /> | |
-- <input type="hidden" name="sessionid" value="nuh" /> | |
-- <input type="hidden" name="ReportHash" value="nope" /> | |
-- <input type="hidden" name="SchoolCode" value="no" /> | |
-- <input type="hidden" name="StudentID" value="idgaf" /> | |
-- <input type="hidden" name="ClassID" value="noid" /> | |
-- <input type="hidden" name="TermID" value="1" /> | |
--lesson plans: https://no.client.renweb.com/pw/student/lesson-plans-print.cfm?studentid=idgaf&weekof=4/17/2016 | |
--schoolcalendar: https://no.client.renweb.com/pw/school/calendar-print.cfm?filter=ALL&studentid=&view=list&month=11&year=2016&day=28&range=month | |
gradeListParse = (str) -> | |
progressReportCapture = '<form action="/renweb/reports/parentsweb/parentsweb_reports.cfm" method="get" target="_blank" id="gradebook_[%d_]*" />' .. | |
'[%s\t]*<input type="hidden" name="District" value="no" />' .. | |
'[%s\t]*<input type="hidden" name="ReportType" value="Gradebook" />' .. | |
'[%s\t]*<input type="hidden" name="sessionid" value="([%d%u%-]*)" />' .. | |
'[%s\t]*<input type="hidden" name="ReportHash" value="([%d%u]*)" />' .. | |
'[%s\t]*<input type="hidden" name="SchoolCode" value="no" />' .. | |
'[%s\t]*<input type="hidden" name="StudentID" value="(%d*)" />' .. | |
'[%s\t]*<input type="hidden" name="ClassID" value="(%d*)" />' .. | |
'[%s\t]*<input type="hidden" name="TermID" value="(%d*)" />' .. | |
'[%s\t]*</form>' | |
si = {} | |
si.classes = {} | |
for sessionid, reporthash, studentid, classid, termid in str\gmatch(progressReportCapture) | |
si.sessionid = sessionid | |
si.reporthash = reporthash | |
si.studentid = studentid | |
table.insert(si.classes, { | |
classid: classid | |
termid: termid | |
}) | |
return si | |
-- gradeParse = (str) -> | |
-- classInfoCapture = '<table width="600" style="border%-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">' .. | |
-- '[%s\t]*<tr>' .. | |
-- '[%s\t]*<td colspan="3" align="center" style="border%-style: none; border%-width: medium">' .. | |
-- '[%s\t]*<div style="border%-bottom%-style: solid; border%-bottom%-width: 1; padding%-bottom: 1">' .. | |
-- '[%s\t]*<p align="center"><b>' .. | |
-- '[%s\t]*<font size="5" face="Arial">Grade Book Student Progress Report</font></b></div>' .. | |
-- '[%s\t]*</td ></tr>' .. | |
-- '[%s\t]*<tr><td align="left" style="border%-style: none; border%-width: medium" >' .. | |
-- '[%s\t]*<font face="Arial"><b>(.*)</b></font></td>' .. --student's name | |
-- '[%s\t]*<td align="center" style="border%-style: none; border%-width: medium">' .. | |
-- '[%s\t]*<font face="Arial"><b>(.*)</b></font></td>' .. --year(s) | |
-- '[%s\t]*<td align="right" style="border%-style: none; border%-width: medium">' .. | |
-- '[%s\t]*<font face="Arial"><b>(.*)</b></font></td></tr>' .. --teacher's name | |
-- '[%s\t]*<tr><td align="left" style="border%-style: none; border%-width: medium">' .. | |
-- '[%s\t]*<font face="Arial"><b>(.*)</b></font></td>' .. --shorten class name | |
-- '[%s\t]*<td align="center" style="border%-style: none; border%-width: medium">' .. | |
-- '[%s\t]*<font face="Arial"><b>(.*)</b></font></td>' .. --quarter | |
-- '[%s\t]*<td style="border%-style: none; border%-width: medium"><p align="right">' .. | |
-- '[%s\t]*<font face="Arial"><b>(.*)</b></font></td></tr>' .. --grading type | |
-- '[%s\t]*<tr>' .. | |
-- '[%s\t]*<td colspan="3" align="left" style="border%-style: none; border%-width: medium">' .. | |
-- '[%s\t]*<div style="border%-bottom%-style: solid; border%-bottom%-width: 1; padding%-bottom: 1">' .. | |
-- '[%s\t]*<font face="Arial"><b>(.*)</b></font></div>' .. --full class name | |
-- '[%s\t]*</td ></tr>' .. | |
-- '[%s\t]*</table>' | |
-- catagoryCapture = '<table width="600" style="border%-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">' .. | |
-- '[%s\t]*<tr>' .. | |
-- '[%s\t]*<td style="border%-bottom%-style: solid; border%-bottom%-width: 1"> </td>' .. | |
-- '[%s\t]*<td style="border%-bottom%-style: solid; border%-bottom%-width: 1"> </td>' .. | |
-- '[%s\t]*<td style="border%-bottom%-style: solid; border%-bottom%-width: 1"> </td></tr>' .. | |
-- '[%s\t]*<tr>' .. | |
-- '[%s\t]*<td align="center" style="border%-bottom%-style: solid; border%-bottom%-width: 1; border%-top%-style:solid; border%-top%-width:1"><b>' .. | |
-- '[%s\t]*<font face="Arial" size="2">(.-)</font></b></td>' .. --catname1 | |
-- '[%s\t]*<td align="center" style="border%-bottom%-style: solid; border%-bottom%-width: 1; border%-top%-style:solid; border%-top%-width:1"><b>' .. | |
-- '[%s\t]*<font face="Arial" size="2">(.-)</font></b></td>' .. --catname2 | |
-- '[%s\t]*<td align="center" style="border%-bottom%-style: solid; border%-bottom%-width: 1; border%-top%-style:solid; border%-top%-width:1"><b>' .. | |
-- '[%s\t]*<font face="Arial" size="2">Weight = ([%d%.]*)</font></b></td></tr>' .. --weigh | |
-- '[%s\t]*</table>' .. | |
-- '[%s\t]*<table width="600" style="border%-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">' .. | |
-- '[%s\t]*<tr><td align="left"><b><font size="1" face="Arial">Assignment</font></b></td>' .. | |
-- '[%s\t]*<td align="center">' .. | |
-- '[%s\t]*<b><font size="1" face="Arial">Pts</font></b></td>' .. | |
-- '[%s\t]*<td align="center"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Max</font></b></td><td align="center"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Avg</font></b></td><td align="center"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Status</font></b></td>' .. | |
-- '[%s\t]*<td align="center"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Due</font></b></td><td align="center"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Curve</font></b></td>' .. | |
-- '[%s\t]*<td align="center"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Bonus</font></b></td>' .. | |
-- '[%s\t]*<td align="center"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Penalty</font></b></td>' .. | |
-- '[%s\t]*<td align="left"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Weight</font></b></td>' .. | |
-- '[%s\t]*<td align="left"><b>' .. | |
-- '[%s\t]*<font size="1" face="Arial">Note</font></b></td></tr>' .. | |
-- '[%s\t]*(.-)' .. --all the gradez | |
-- '[%s\t]*<tr><td>' .. | |
-- '[%s\t]*<p align="left"><b><font size="2" face="Arial">Category Average</font></b></td><td>' .. | |
-- '[%s\t]*<p align="center"><b>' .. | |
-- '[%s\t]*<font size="2" face="Arial">' .. | |
-- '[%s\t]*([%d%.]*)' .. --the average | |
-- '[%s\t]*</font></b></td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>' | |
-- assignmentCapture = '<tr>' .. | |
-- '[%s\t]*<td align="left"><font size="1" face="Arial">(.-)</font></td>' .. --assignment | |
-- '[%s\t]*<td align="center"><?f?o?n?t? ?s?i?z?e?=?"?1?"? ?f?a?c?e?=?"?A?r?i?a?l?"? ?c?o?l?o?r?=?"?B?l?a?c?k?"?>?%s*([%d%.]*)<?/?f?o?n?t?>?</td>' .. --pts | |
-- '[%s\t]*<td align="center"><?f?o?n?t? ?s?i?z?e?=?"?1?"? ?f?a?c?e?=?"?A?r?i?a?l?"? ?c?o?l?o?r?=?"?B?l?a?c?k?"?>?%s*([%d%.]*)<?/?f?o?n?t?>?</td>' .. --max | |
-- '[%s\t]*<td align="center"><?f?o?n?t? ?s?i?z?e?=?"?1?"? ?f?a?c?e?=?"?A?r?i?a?l?"? ?c?o?l?o?r?=?"?B?l?a?c?k?"?>?%s*([%d%.]*)<?/?f?o?n?t?>?</td>' .. --avg | |
-- '[%s\t]*<td align="center"><font size="1" face="Arial" color="Black">(.-)</font></td>' .. --status | |
-- '[%s\t]*<td align="center"><font size="1" face="Arial" color="Black">([%d/]*)</font></td>' .. --due | |
-- '[%s\t]*<td align="center"><font size="1" face="Arial" color="Black">([%d%.]*)</font></td>' .. --curve | |
-- '[%s\t]*<td align="center"><font size="1" face="Arial" color="Black">([%d%.]*)</font></td>' .. --bonus | |
-- '[%s\t]*<td align="center"><font size="1" face="Arial" color="#FF0000">(.-)</font></td>' .. --penalty | |
-- '[%s\t]*<td align="center"><font size="1" face="Arial" color="Black">([%d%.]*)</font></td>' .. --weight | |
-- '[%s\t]*<td align="left"><font size="1" face="Arial" color="Black">(.-)</font></td>' .. --note | |
-- '[%s\t]*</tr>' | |
-- termGradeCapture = '<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>' .. | |
-- '[%s\t]*<tr><td><b><font size="2" face="Arial">Term Grade</font></b></td><td>' .. | |
-- '[%s\t]*<b><font size="2" face="Arial" >' .. | |
-- '[%s\t]*([%d%.]*)' .. | |
-- '[%s\t]*</font></b></td><td>' .. | |
-- '[%s\t]*<b>' .. | |
-- '[%s\t]*<font size="2" face="Arial" >(%u*)</font></b></td>' .. | |
-- '[%s\t]*<td></td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td>' .. | |
-- '[%s\t]*</tr>' | |
-- studentName, years, teacherName, shortClassName, quarter, gradingType, fullClassName = str\match(classInfoCapture) | |
-- termGrade, termLetter = str\match(termGradeCapture) | |
-- info = { | |
-- studentName: studentName | |
-- years: years | |
-- teacherName: teacherName | |
-- shortClassName: shortClassName | |
-- quarter: quarter | |
-- gradingType: gradingType | |
-- fullClassName: fullClassName | |
-- termGrade: termGrade | |
-- termLetter: termLetter | |
-- catagories: {} | |
-- } | |
-- for catname1, catname2, weigh, gradeinfo, average in str\gmatch(catagoryCapture) | |
-- catinfo = { | |
-- catname1: catname1 | |
-- catname2: catname2 | |
-- weigh: weigh | |
-- assignments: {} | |
-- average: average | |
-- } | |
-- for assignment, pts, max, avg, status, due, curve, bonus, penalty, weight, note in gradeinfo\gmatch(assignmentCapture) | |
-- table.insert(catinfo.assignments, { | |
-- assignment: assignment | |
-- pts: pts | |
-- max: max | |
-- avg: avg | |
-- status: status | |
-- due: due | |
-- curve: curve | |
-- bonus: bonus | |
-- penalty: penalty | |
-- weight: weight | |
-- note: note | |
-- }) | |
-- table.insert(info.catagories, catinfo) | |
-- return info | |
-- lessonPlansParse = (str) -> | |
-- lessonPlansDayCapture = '<li class="dateli">' .. | |
-- '[%s\t]*<div class="datehw">([%d/]*) %- (.-)</div>' .. -- date mm/dd/yy, day of the week | |
-- '[%s\t]*(.-)' .. --all homework_items | |
-- '[%s\t]*</li>' | |
-- homeworkItemCapture = '<div class="homework_item"><span class="hwclass">(.-) %-</span> (.-)</div>' --class, item | |
-- days = {} | |
-- for date, day, items in str\gmatch(lessonPlansDayCapture) | |
-- dat = { | |
-- date: date | |
-- day: day | |
-- items: {} | |
-- } | |
-- for classs, item in items\gmatch(homeworkItemCapture) | |
-- table.insert(dat.items, { | |
-- class: classs | |
-- item: item\gsub("<br>", "\n") | |
-- }) | |
-- table.insert(days, dat) | |
-- return days | |
-- homeworkCalendarParse = (str) -> | |
-- homeworkCalendarCapture = '<tr>' .. | |
-- '[%s\t]*<td>([%d/]*)</td>' .. --date mm/dd/yy | |
-- '[%s\t]*<td>(.-)</td>' .. --day of the week (monday, tuesday, wednesday, etc) | |
-- '[%s\t]*<td>' .. | |
-- '[%s\t]*<div class="evt_title with_link"><span class="homework%-student">(.-)</span>: <span class="homework%-class">(.-)</span><div class="homework%-describe">(.-)</div></div>' .. --student, class, description | |
-- '[%s\t]*<div class="evt_msg">' .. | |
-- '[%s\t]*<div><strong>Description:</strong><br />(.-)</div> ' .. --description2 | |
-- '[%s\t]*</div>' .. | |
-- '[%s\t]*</td>' | |
-- hwcal = {} | |
-- for date, day, student, classs, description, description2 in str\gmatch(homeworkCalendarCapture) | |
-- table.insert(hwcal, { | |
-- date: date | |
-- day: day | |
-- student: student | |
-- class: classs | |
-- description: description\gsub("<br />", "\n") | |
-- --description2: description2 | |
-- }) | |
-- return hwcal | |
gradeListCleanup = (str) -> | |
return str\gsub('<input type="hidden" name="ReportHash" value="([%d%u]*)" />', '')\gsub('<input type="hidden" name="sessionid" value="([%d%u%-]*)" />', '') | |
file_util = require"file_util" | |
-- serpent = require"serpent" | |
-- JSON = require"JSON" | |
-- print(serpent.block(gradeListParse(file_util.readfile("gradeslist_ex.html")))) | |
-- print(serpent.block(gradeParse(file_util.readfile("grades_ex.html")))) | |
-- print(serpent.block(lessonPlansParse(file_util.readfile("lessonplans_ex.html")))) | |
-- print(serpent.block(homeworkCalendarParse(file_util.readfile("homework_calendar_list_ex.html")))) | |
-- os.exit(0) | |
file = io.popen(file_util.shellargs("curl", "-s", "-X", "POST", "--cookie-jar", "-", "https://no.client.renweb.com/pw/index.cfm", "--data", "DistrictCode=no&username=fuck&password=kuso&UserType=PARENTSWEB-STUDENT&login=Login", "--compressed"), "r") | |
lbpersist = nil | |
cfid = nil | |
cftoken = nil | |
for line in file\lines! | |
if line\sub(1, 25) == "no.client.renweb.com" | |
strt, ennd = line\find("LB-Persist\t", 1, true) | |
if strt | |
lbpersist = line\sub(ennd + 1) | |
strt, ennd = line\find("CFID\t", 1, true) | |
if strt | |
cfid = line\sub(ennd + 1) | |
strt, ennd = line\find("CFTOKEN\t", 1, true) | |
if strt | |
cftoken = line\sub(ennd + 1) | |
cookie = "CFID=" .. cfid .. "; CFTOKEN=" .. cftoken .. "; LB-Persist=" .. lbpersist | |
os.execute(file_util.shellargs("curl", "--silent", "--cookie", cookie, "--compressed", "--create-dirs", "https://no.client.renweb.com/pw/student/grades.cfm", "--output", "gradeslistblob.html")) | |
gradeslistblob = file_util.readfile("gradeslistblob.html") | |
alllsgr = gradeListParse(gradeslistblob) | |
file_util.writefile("log/gradeslist.html", gradeListCleanup(gradeslistblob)) | |
get_days_in_month = (mnth, yr) -> | |
return os.date('*t',os.time{year:yr,month:mnth+1,day:0})['day'] | |
yrs = {2017, 2018} | |
allargs = {} | |
for i, y in pairs(yrs) | |
for m = 1, 12 | |
table.insert(allargs, "https://no.client.renweb.com/pw/school/calendar-print.cfm?filter=Homework&view=list&month=" .. m .. "&year=" .. y .. "&range=month") | |
table.insert(allargs, "-o") | |
table.insert(allargs, "log/" .. m .. "*" .. y .. "hwcal.html") | |
table.insert(allargs, "https://no.client.renweb.com/pw/school/calendar-print.cfm?filter=ALL&view=list&month=" .. m .. "&year=" .. y .. "&range=month") | |
table.insert(allargs, "-o") | |
table.insert(allargs, "log/" .. m .. "*" .. y .. "cal.html") | |
d = get_days_in_month(m,y) | |
d7 = (math.floor(d / 7) == (d / 7)) and math.floor(d / 7) or (math.floor(d / 7) + 1) | |
for w = 1, d7 | |
if alllsgr.studentid | |
table.insert(allargs, "https://no.client.renweb.com/pw/student/lesson-plans-print.cfm?studentid=" .. alllsgr.studentid .. "&weekof=" .. m .. "/" .. (((w-1)*7)+1) .. "/" .. y) | |
table.insert(allargs, "-o") | |
table.insert(allargs, "log/" .. m .. "*" .. w .. "*" .. y .. "lessonplan.html") | |
for i, v in pairs(alllsgr.classes) | |
table.insert(allargs, "https://no.client.renweb.com/renweb/reports/parentsweb/parentsweb_reports.cfm?District=no&ReportType=Gradebook&sessionid=" .. alllsgr.sessionid .. "&ReportHash=" .. alllsgr.reporthash .. "&SchoolCode=no&StudentID=" .. alllsgr.studentid .. "&ClassID=" .. v.classid .. "&TermID=" .. v.termid) | |
table.insert(allargs, "-o") | |
table.insert(allargs, "log/" .. v.classid .. "*" .. v.termid .. ".html") | |
-- file_util.writefile("watter.json", JSON\encode_pretty(biginfo)) | |
--download everything | |
os.execute(file_util.shellargs("curl", "--silent", "--location", "--cookie", cookie, "--compressed", "--create-dirs", unpack(allargs))) | |
--gtfo | |
os.execute(file_util.shellargs("curl", "--silent", "--cookie", cookie, "--compressed", "--create-dirs", "https://no.client.renweb.com/pw/?LogOut=1")) | |
os.execute(file_util.shellargs("git", "-C", "log", "add", "--all")) | |
os.execute(file_util.shellargs("git", "-C", "log", "commit", "--all", "--message", "Renweb automated sync")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment