Last active
July 20, 2024 23:35
-
-
Save codingtony/b667b9b1feed1cb3af6e221acd7085b0 to your computer and use it in GitHub Desktop.
Get school list from fraser institute as CSV
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
#!/bin/bash | |
wget https://www.compareschoolrankings.org/api/v1/schools.json -O school.json | |
jq '.data[] | { sid:.sid, title:.title, province:.province, type:.schoolType, rank:.schoolInfoData."Rank This Yr", city:.schoolInfoData.SchoolCity, pubOrPriv:.schoolInfoData.IND_or_PUB,lang:.schoolInfoData.SchoolLanguage,admin:.schoolInfoData.AdminBodyName } ' school.json | jq -rn -L. 'include "json2csv"; [inputs]|json2csv' > school.csv |
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
def json2headers: | |
def isscalar: type | . != "array" and . != "object"; | |
def isflat: all(.[]; isscalar); | |
paths as $p | |
| getpath($p) | |
| if type == "array" and isflat then $p | |
elif isscalar and (($p[-1]|type) == "string") then $p | |
else empty end ; | |
def json2array($header): | |
def value($p): | |
try getpath($p) catch null | |
| if type == "object" then null else . end; | |
[$header[] as $p | value($p)]; | |
def json2csv: | |
( [.[] | json2headers] | unique) as $h | |
| ([$h[]|join("_") ], | |
(.[] | |
| json2array($h) | |
| map( if type == "array" then map(tostring)|join("|") else tostring end))) | |
| @csv ; |
Yes it seems to be encrypted. The key seems to be in the javascript
getProvinceLatestYear: function() {
return Object(o["a"])(regeneratorRuntime.mark((function e() {
var t;
return regeneratorRuntime.wrap((function(e) {
while (1)
switch (e.prev = e.next) {
case 0:
return t = "".concat(P, "/province_latest_year.json"), e.next = 3, w.get(t).catch((function(e) {
console.error(e)
}));
case 3:
return e.abrupt("return", e.sent);
case 4:
case "end":
return e.stop()
}
}), e)
})))()
}
},
j = function() {
function e() {
var t = this;
Object(r["a"])(this, e),
this.hashMap = {},
this.keySalt = "phaiy7aeHieX`ieV",
this.eKey = "Xuhahxu7si3Ke]z@",
this.bypass = ["language", "appVersion"],
["latestYear", "userLocation", "userAddress", "currentMapProvice", "schoolData", "school_average", "areaNames"].forEach((function(e) {
return t.migrate(e)
}))
}
return Object(s["a"])(e, [{
key: "hashKey",
value: function(e) {
return this.hashMap[e] || (this.hashMap[e] = u.a.SHA1(e + this.keySalt).toString().substr(2, 16)), this.hashMap[e]
}
}, {
key: "migrate",
value: function(e) {
var t = localStorage.getItem(e);
if (null === t)
return !1;
var a = t.length;
"=" === t.substr(4, 1) && "=" === t.substr(a - 5, 1) || this.setItem(e, t),
localStorage.removeItem(e)
}
}, {
key: "getItem",
value: function(e) {
if (-1 !== this.bypass.indexOf(e))
return localStorage.getItem(e);
this.migrate(e);
var t = this.hashKey(e),
a = localStorage.getItem(t);
if (null === a)
return null;
var o = a.length;
if ("=" !== a.substr(4, 1) || "=" !== a.substr(o - 5, 1))
return localStorage.removeItem(t), null;
var n = u.a.AES.decrypt(a.substr(5, o - 10), u.a.SHA1(this.eKey + a.substr(0, 4) + a.substr(o - 4)).toString()).toString(u.a.enc.Utf8);
return n || (localStorage.removeItem(t), null)
}
}, {
key: "generateSalt",
value: function() {
return u.a.lib.WordArray.random(4).toString(u.a.enc.Hex)
}
}, {
key: "setItem",
value: function(e, t) {
if (-1 !== this.bypass.indexOf(e))
return localStorage.setItem(e, t);
var a = this.generateSalt();
localStorage.setItem(this.hashKey(e), a.substr(0, 4) + "=" + u.a.AES.encrypt(t, u.a.SHA1(this.eKey + a).toString()) + "=" + a.substr(4))
}
}, {
key: "removeItem",
value: function(e) {
localStorage.removeItem(this.hashKey(e))
}
}]), e
}()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems not working anymore. It looks like what the api returns is encrypted or encoded now.