Loadshedding API?

The_Ogre

Honorary Master
Joined
Apr 30, 2010
Messages
25,146
I'd love to make use of an API like this. The amount of people in my neighbourhood watch group who don't know how to interpret the schedule is staggering.

I'm sure I can slap an android app together in a couple of minutes if only I can find an API. I don't have the time and energy to scrape for something which I'm not ggoing to get paid for :laugh:
 

Jade @ Absolute Hosting

Absolute Hosting Representative
Company Rep
Joined
Nov 17, 2015
Messages
1,109
We use eskomsepoesh and it works well, why not install it and save yourself all that effort, unless you wanna dev some things better
 

Steamy Tom

Executive Member
Joined
Jan 23, 2019
Messages
7,395
I'd love to make use of an API like this. The amount of people in my neighbourhood watch group who don't know how to interpret the schedule is staggering.

I'm sure I can slap an android app together in a couple of minutes if only I can find an API. I don't have the time and energy to scrape for something which I'm not ggoing to get paid for :laugh:

You could drive around in your car with a 5 story neon sign and a 500 decibal loudspeaker and people will still not understand what is going on because they are dumb af. If I had 0.000000001c for every person that asked for a loadshedding schedule (which hasn't changed by us in several years) I would be a millionaire just for today.

The eskomsepush app works pretty well even though I don't use it.
 

CT_Biker

Expert Member
Joined
Sep 10, 2016
Messages
2,576
You're better off using Beautiful Soup and scraping data off twitter, I am not sure if BS can scrape location information from tweets. Whether or not geo-local is displayed is, is the users choice and not Twitter's.
 
Last edited:

JamesBoy

Well-Known Member
Joined
Mar 31, 2017
Messages
300
You're better off using Beautiful Soup and scraping data off twitter, I am not sure if BS can scrape location information from tweets. Whether or not geo-local is displayed is, is the users choice and not Twitter's.
How does this compare to something like the HTML Agility pack in terms of usability? The one issue I had with the HTML Agility pack was that it only really works on a completely loaded document and won't trigger scripts to load the dynamic bits.
 

CT_Biker

Expert Member
Joined
Sep 10, 2016
Messages
2,576
How does this compare to something like the HTML Agility pack in terms of usability? The one issue I had with the HTML Agility pack was that it only really works on a completely loaded document and won't trigger scripts to load the dynamic bits.

You're a .NET guy? BeautifulSoup has the same issue with dynamic content, just as a heads up - Selenium gives you the option to set a waiter and trigger DHTML. That might help you , but you will need to do some further research.
 

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
38,382
Selenium FTFW!

Anyway, if you are an Eskom customer you can just check the AJAX calls their site makes and skip firing up a browser instance to scrape HTML content that's generated client side.

Example:

\http://loadshedding.eskom.co.za/LoadShedding/FindSuburbssearchText=Broadacres+AH&maxResults=300

Code:
[{"MunicipalityName":"City of Johannesburg",... "Id":1020571,"Total":405},
{"MunicipalityName":"City of Johannesburg",..."Id":1020572,"Total":135},
{"MunicipalityName":"City of Johannesburg",... "Id":1020573,"Total":270}]

Use one of the records' ID and loadshedding stage as parameters:
\http://loadshedding.eskom.co.za/LoadShedding/GetScheduleM/1020571/2/3/405?_=1576127221434

And you'll get some HTML you can scrape which renders to this:
Code:
Thu, 12 Dec
08:00 - 12:30
Fri, 13 Dec
00:00 - 04:30
Sat, 14 Dec
-
Sun, 15 Dec
00:00 - 04:30
16:00 - 20:30
Mon, 16 Dec
-
Tue, 17 Dec
12:00 - 16:30
Wed, 18 Dec
04:00 - 08:30
 

argh

Well-Known Member
Joined
Sep 17, 2019
Messages
133
On an Android smartphone, I use "Load Shedding Notifier" and/or "EskomSePush". These are two free apps available from the Google store. Both provide very reliable and rapidly updated information. Both were updated this week with schedules up to Stage 8.
 

biometrics

Honorary Master
Joined
Aug 7, 2003
Messages
71,861
Selenium FTFW!

Anyway, if you are an Eskom customer you can just check the AJAX calls their site makes and skip firing up a browser instance to scrape HTML content that's generated client side.

Example:

\http://loadshedding.eskom.co.za/LoadShedding/FindSuburbssearchText=Broadacres+AH&maxResults=300

Code:
[{"MunicipalityName":"City of Johannesburg",... "Id":1020571,"Total":405},
{"MunicipalityName":"City of Johannesburg",..."Id":1020572,"Total":135},
{"MunicipalityName":"City of Johannesburg",... "Id":1020573,"Total":270}]

Use one of the records' ID and loadshedding stage as parameters:
\http://loadshedding.eskom.co.za/LoadShedding/GetScheduleM/1020571/2/3/405?_=1576127221434

And you'll get some HTML you can scrape which renders to this:
Code:
Thu, 12 Dec
08:00 - 12:30
Fri, 13 Dec
00:00 - 04:30
Sat, 14 Dec
-
Sun, 15 Dec
00:00 - 04:30
16:00 - 20:30
Mon, 16 Dec
-
Tue, 17 Dec
12:00 - 16:30
Wed, 18 Dec
04:00 - 08:30
What are the other parameters and there is also cache busting taking place?
 

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
38,382
What are the other parameters and there is also cache busting taking place?

No idea, if you're going to parse them you're going to have to investigate. I would assume the random text at the end is the cache busting, you can always add your own as well.

That said, if you're creating a bot or app of some sort making HTTP requests you shouldn't need to worry about client side caching unless you implemented it yourself. You wouldn't want to mess with server side caching either because it is there for a reason.
 

zippy

Honorary Master
Joined
May 31, 2005
Messages
10,060
Thing is its never accurate which sucks. If you guys could develop and accurate app that would be cool
A simple script recording when your UPS kicks in would probably be more helpful :)
 

biometrics

Honorary Master
Joined
Aug 7, 2003
Messages
71,861
Ok so I got stuck into this today for a community website. Feel free to edit the following. Replace anything in <> with the relevant value.

Get the current status (as posted earlier):

Call: http://loadshedding.eskom.co.za/LoadShedding/GetStatus
Returned data: Is a single character/value. If less than 1 then discard. If more or equal subtract 1 for the current stage.
Example: 1 = No load shedding, 2 = Stage 1, 5 = Stage 4

Get the schedule:

Province IDs:
1 = Eastern Cape
2 = Free State
3 = Gauteng
4 = KwaZulu-Natal
5 = Limpopo
6 = Mpumalanga
7 = North West
8 = Northern Cape
9 = Western Cape

List municipalitied in province:
Call: http://loadshedding.eskom.co.za/LoadShedding/GetMunicipalities/?Id=<province_id>
Example (Province = Western Cape): http://loadshedding.eskom.co.za/LoadShedding/GetMunicipalities/?Id=9
Returned JSON:
Code:
[{"Selected":false,"Text":"Beaufort West","Value":"10237"},{"Selected":false,"Text":"Bergrivier","Value":"10238"},{"Selected":false,"Text":"Bitou","Value":"10239"},{"Selected":false,"Text":"Breede Valley","Value":"10240"},{"Selected":false,"Text":"Cape Agulhas","Value":"10241"},{"Selected":false,"Text":"Cederberg","Value":"10242"},{"Selected":false,"Text":"City of Cape Town","Value":"10243"},{"Selected":false,"Text":"Drakenstein","Value":"10244"},{"Selected":false,"Text":"George","Value":"10245"},{"Selected":false,"Text":"Hessequa","Value":"10246"},{"Selected":false,"Text":"Kannaland","Value":"10247"},{"Selected":false,"Text":"Knysna","Value":"10248"},{"Selected":false,"Text":"Laingsburg","Value":"10249"},{"Selected":false,"Text":"Langeberg","Value":"10250"},{"Selected":false,"Text":"Matzikama","Value":"10251"},{"Selected":false,"Text":"Mossel Bay","Value":"10252"},{"Selected":false,"Text":"Oudtshoorn","Value":"10253"},{"Selected":false,"Text":"Overstrand","Value":"10254"},{"Selected":false,"Text":"Prince Albert","Value":"10255"},{"Selected":false,"Text":"Saldanha Bay","Value":"10256"},{"Selected":false,"Text":"Stellenbosch","Value":"10257"},{"Selected":false,"Text":"Swartland","Value":"10258"},{"Selected":false,"Text":"Swellendam","Value":"10259"},{"Selected":false,"Text":"Theewaterskloof","Value":"10260"},{"Selected":false,"Text":"Witzenberg","Value":"10261"}]

List suburbs of municipality:
Call: http://loadshedding.eskom.co.za/LoadShedding/GetSurburbData/?pageSize=100&pageNum=1&id=<municipality_id>
Example (Municipality = Overstrand): http://loadshedding.eskom.co.za/LoadShedding/GetSurburbData/?pageSize=100&pageNum=1&id=10254
- include the pageSize and pageNum parameters or the call will fail.
Returned JSON:
Code:
{"Total":111,"Results":[{"id":"1061253","text":"Afdak","Tot":267},{"id":"1069253","text":"Albertyn","Tot":535},{"id":"1061254","text":"Avila","Tot":0},{"id":"1061255","text":"Avoca","Tot":268},{"id":"1061256","text":"Baardskeerdersbos","Tot":268},{"id":"1061257","text":"Betty\u0027s Bay","Tot":268},{"id":"1061258","text":"Birkenhead","Tot":0},{"id":"1061259","text":"Blompark","Tot":0},{"id":"1061260","text":"Boesmansrivier","Tot":268},{"id":"1061261","text":"Bovendrift","Tot":268},{"id":"1061262","text":"Braemar","Tot":268},{"id":"1061263","text":"Bruinklip","Tot":268},{"id":"1061264","text":"Buffeljacht","Tot":272},{"id":"1069254","text":"Dagbreek","Tot":534},{"id":"1069255","text":"De Hoop","Tot":267},{"id":"1061265","text":"De Kelders","Tot":0},{"id":"1061266","text":"De Kelders 2","Tot":0},{"id":"1061267","text":"De Kelders 3","Tot":0},{"id":"1069256","text":"Denniston","Tot":267},{"id":"1061268","text":"Die Dam","Tot":272},{"id":"1061269","text":"Dirkuyskraal","Tot":272},{"id":"1061270","text":"Doringbosch","Tot":268},{"id":"1061271","text":"Duinefontein","Tot":0},{"id":"1061272","text":"Eluxolweni","Tot":0},{"id":"1061273","text":"Ertjiesvlei","Tot":268},{"id":"1061274","text":"Fisantskraal","Tot":272},{"id":"1061275","text":"Fisherhaven","Tot":267},{"id":"1061276","text":"Franskraal Strand","Tot":268},{"id":"1061277","text":"Gans Bay","Tot":536},{"id":"1061278","text":"Goedetrouw","Tot":268},{"id":"1061279","text":"Groenewaldskema","Tot":0},{"id":"1061280","text":"Groot Hagelkraal","Tot":0},{"id":"1061281","text":"Grootbos","Tot":268},{"id":"1061282","text":"Grootvlei","Tot":268},{"id":"1061283","text":"Hagelkraal","Tot":0},{"id":"1061284","text":"Hangklip","Tot":268},{"id":"1061285","text":"Hawston","Tot":0},{"id":"1061286","text":"Helderfontein","Tot":0},{"id":"1061287","text":"Hermanus","Tot":2412},{"id":"1061288","text":"Hermanus Outlying","Tot":0},{"id":"1061289","text":"High Noon","Tot":267},{"id":"1061290","text":"Honigsklip","Tot":268},{"id":"1061291","text":"Hoopjesrivier","Tot":267},{"id":"1061292","text":"Houhoek","Tot":267},{"id":"1061293","text":"Karwyderskraal","Tot":268},{"id":"1061294","text":"Kleinbaai","Tot":0},{"id":"1061295","text":"Kleinmond","Tot":536},{"id":"1061296","text":"Kleinrivierkloof","Tot":268},{"id":"1061297","text":"Klipfontein","Tot":0},{"id":"1061298","text":"Koksrivier","Tot":272},{"id":"1061299","text":"Kouderivier","Tot":268},{"id":"1061300","text":"Kouevlakte","Tot":268},{"id":"1069257","text":"Kromvlei","Tot":267},{"id":"1061301","text":"Lamloch","Tot":268},{"id":"1061302","text":"Langkloof","Tot":0},{"id":"1061303","text":"Le Mercy","Tot":268},{"id":"1069258","text":"Lebanon","Tot":267},{"id":"1061304","text":"LObos","Tot":0},{"id":"1061305","text":"Masakhane","Tot":0},{"id":"1061306","text":"Modderrivier","Tot":268},{"id":"1061307","text":"Moeraskloof","Tot":268},{"id":"1061308","text":"Mosselrivier","Tot":0},{"id":"1061309","text":"Mount Pleasant","Tot":0},{"id":"1061310","text":"New Granton","Tot":268},{"id":"1061311","text":"Nuwedam","Tot":268},{"id":"1061312","text":"Nuwepos","Tot":268},{"id":"1061313","text":"Onrus","Tot":535},{"id":"1061314","text":"Oudebosch","Tot":268},{"id":"1061315","text":"Paardenberg","Tot":268},{"id":"1061316","text":"Papiesvlei","Tot":268},{"id":"1061317","text":"Pearly Beach","Tot":0},{"id":"1061318","text":"Perlemoenbaai","Tot":0},{"id":"1061319","text":"Pringle Bay","Tot":268},{"id":"1061320","text":"Protea","Tot":0},{"id":"1061321","text":"Ratelrivier","Tot":272},{"id":"1061322","text":"Rooiels Bay","Tot":268},{"id":"1069259","text":"Salandra","Tot":268},{"id":"1061323","text":"Sandbaai","Tot":268},{"id":"1061324","text":"Sandberg","Tot":268},{"id":"1069260","text":"Sandfontein","Tot":272},{"id":"1061325","text":"Sandhoogte","Tot":268},{"id":"1061326","text":"Sandy\u0027s Glen","Tot":268},{"id":"1061327","text":"Silversands","Tot":268},{"id":"1061328","text":"Somerset West NU","Tot":0},{"id":"1061329","text":"Spookfontein","Tot":536},{"id":"1061330","text":"Stanford","Tot":804},{"id":"1061331","text":"Stompieskloof","Tot":0},{"id":"1061332","text":"Strands Kloof","Tot":268},{"id":"1061333","text":"Sunny Seas Estate","Tot":268},{"id":"1061334","text":"Sunnydale","Tot":804},{"id":"1061335","text":"The Springs","Tot":0},{"id":"1061336","text":"Tierfontein","Tot":268},{"id":"1061337","text":"Tweefontein","Tot":268},{"id":"1061338","text":"Uilenkraal","Tot":268},{"id":"1061339","text":"Uilenkraalsmond","Tot":268},{"id":"1061340","text":"Uitkoms","Tot":268},{"id":"1061341","text":"Van Dyksbaai","Tot":0},{"id":"1061342","text":"Vermont","Tot":267},{"id":"1061343","text":"Viljoenshof","Tot":272},{"id":"1069261","text":"Vredendal","Tot":268}]}
- If Tot is 0 then there won't be further data.

List load shedding schedule for suburb:
Call: http://loadshedding.eskom.co.za/LoadShedding/GetScheduleM/<suburb_id>/<stage>/<province_id>/<municipality_total>
- municipality_total must be 1 or more.
Example (Suburb = Hermanus, Stage = 2, Province = 9 (Western Cape)): http://loadshedding.eskom.co.za/LoadShedding/GetScheduleM/1061287/2/9/1
Returned HTML (you will need to parse this):

Wed, 08 Jan

18:00 - 20:30


Thu, 09 Jan

00:00 - 02:30


Fri, 10 Jan

00:00 - 02:30

08:00 - 10:30
 
Last edited:
Top