Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


davidcole

6037 posts

Uber Geek

Trusted

#215279 20-Jun-2017 12:21
Send private message

On the back of this tread: https://www.geekzone.co.nz/forums.asp?forumid=48&topicid=215278  I started looking at the Genesis page.


Anyone tried scraping their usage data off their site since they're too annoyingd to provide an API (I asked, and was told they could email it to me each time - what is this 1995?)


 





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


View this topic in a long page with up to 500 replies per page Create new topic
 1 | 2 | 3
mattrix
193 posts

Master Geek
Inactive user


  #1803972 20-Jun-2017 12:53
Send private message

Python + Requests library should make it a breeze.
Use a Requests session so you can "login" and then scrape the data.
I do pretty much the same thing with EK.

import requests
s= requests.session()
s.post('http://example.com/login', data={'username':'MrX','password':'123'})
r = s.get('http://example.com/secure_page')
print(r.text)




davidcole

6037 posts

Uber Geek

Trusted

  #1803974 20-Jun-2017 12:56
Send private message

Yeah I'm looking at their source and there's not much to it, ie no values.

 

The data I think is in here:

 

<script type="text/javascript" src="/ruxitagentjs_2fqr_10119170522100716.js" data-dtconfig="rid=RID_1234567890|rpid=-1234567890|domain=genesisenergy.co.nz|reportUrl=/rb_xxx12345|lastModification=1496750138877|tp=500,50,0,1"></script>

 

Which I'm guessing is a call to an external data source provider.





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


davidcole

6037 posts

Uber Geek

Trusted

  #1803981 20-Jun-2017 13:05
Send private message

This might be the backend: 

 

https://help.dynatrace.com/dynatrace-api/timeseries/how-do-i-fetch-the-metrics-of-monitored-entities/

 

https://github.com/Dynatrace/dynatrace-api

 

 





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 




Yabanize
2350 posts

Uber Geek


  #1803988 20-Jun-2017 13:24
Send private message

Open developer tools in Chrome and look in the network tab to see what requests are being made as the page loads, Look at each one and you can view the request and responses


marpada
476 posts

Ultimate Geek


  #1804012 20-Jun-2017 13:35
Send private message

There's a post request to https://myaccount-api.genesisenergy.co.nz/api/usage . Now you just need to figure out how to generate the authorization token :)


davidcole

6037 posts

Uber Geek

Trusted

  #1804013 20-Jun-2017 13:36
Send private message

Hmm I see:

 

https://myaccount-api.genesisenergy.co.nz/api/usage

 

 

 

With a json response:

 

[
{
"date": "2017-06-16T00:00:00+12:00",
"usage": 28.74,
"dollars": 8.2990578,
"highlight": false,
"estimate": false
}

 

]

 

 

 

But need to figure out the parms it uses for the post





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


davidcole

6037 posts

Uber Geek

Trusted

  #1804020 20-Jun-2017 13:45
Send private message

marpada:

 

There's a post request to https://myaccount-api.genesisenergy.co.nz/api/usage . Now you just need to figure out how to generate the authorization token :)

 

 

So does that mean it's a post to that api site with the one parm of authorization?

 

I never figured out how to translate those post requests into actual requests.

 

Plus there looks like there's a cookie being set as well.





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


 
 
 

Trade NZ and US shares and funds with Sharesies (affiliate link).
davidcole

6037 posts

Uber Geek

Trusted

  #1804027 20-Jun-2017 13:51
Send private message

Surely that cookie is being used for the what data to present.  The only difference I can see between a request for this month and last month is a set cookie.  The authorization string stays the same, and there's no other parms being used.





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


sidefx
3714 posts

Uber Geek

Trusted

  #1804031 20-Jun-2017 13:56
Send private message

davidcole:

 

Anyone tried scraping their usage data off their site since they're too annoyingd to provide an API (I asked, and was told they could email it to me each time - what is this 1995?) 

 

 

 

 

Automatically email it or only when you ask?  And what frequency and format?

 

Yeah it's nowhere near as good as a proper API but it might be easier than trying to scrape and reverse engineer their authentication scheme? (I don't use genesis so can't look at theirs... I may look at what contact offers though because I've been wanting to do something similar too :)





"I was born not knowing and have had only a little time to change that here and there."         | Octopus Energy | Sharesies
              - Richard Feynman


davidcole

6037 posts

Uber Geek

Trusted

  #1804034 20-Jun-2017 13:59
Send private message

sidefx:

 

davidcole:

 

Anyone tried scraping their usage data off their site since they're too annoyingd to provide an API (I asked, and was told they could email it to me each time - what is this 1995?) 

 

 

 

 

Automatically email it or only when you ask?  And what frequency and format?

 

Yeah it's nowhere near as good as a proper API but it might be easier than trying to scrape and reverse engineer their authentication scheme? (I don't use genesis so can't look at theirs... I may look at what contact offers though because I've been wanting to do something similar too :)

 

 

 

 

Automatic, ha ha ha ha ha ha ha ha ha what planet do you think this is.

 

No on request. and I can't remember the formatting - given it's a corporate - it'd be "excel" or "excel csv" - much lols.

 

I can go into their usage and download to csv the usage, which I could then parse (I'm wanting to push it into influxdb to I can graph it with grafana) - just for giggles.  I have gas readings already - as I read that once a day to an app which does have an api.

 

 





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


mattrix
193 posts

Master Geek
Inactive user


  #1804037 20-Jun-2017 14:03
Send private message

You will need to work out how it's logging you in.
Once you get that session cookie, you should be able to call the other methods.

Looking at the XHR request, it's making an OPTIONS request to:
https://myaccount-api.genesisenergy.co.nz/api/authorize

 

Looking at the form input names, looks like 'username' and 'password'.
So, try:

 

import requests
s= requests.session()
r = s.options('https://myaccount-api.genesisenergy.co.nz/api/authorize', data={'username':'MrX','password':'123'})
print(r.text)

I'm not with them so can't test.
It's quite odd to do an options request with data, so not sure if that's right.
But, without being a customer - I can't really see any requests after that.

Once you can mange to login, you will get the session cookie that you can then send with all other requests (request sessions will automatically do that).

 


Another great way to test without Python, is use Chrome Postman
https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en

That let's you build and send requests :)
Really good!


sidefx
3714 posts

Uber Geek

Trusted

  #1804042 20-Jun-2017 14:18
Send private message

davidcole: 

 

Automatic, ha ha ha ha ha ha ha ha ha what planet do you think this is.

 

 

 

 

 

 

lol, yeah I guess that was a tad hopeful ;-)   blergh... just looked at the requests on the contact energy site... loads of SAP crap.





"I was born not knowing and have had only a little time to change that here and there."         | Octopus Energy | Sharesies
              - Richard Feynman


davidcole

6037 posts

Uber Geek

Trusted

  #1804106 20-Jun-2017 15:06
Send private message

mattrix:

 

You will need to work out how it's logging you in.
Once you get that session cookie, you should be able to call the other methods.

Looking at the XHR request, it's making an OPTIONS request to:
https://myaccount-api.genesisenergy.co.nz/api/authorize

 

Looking at the form input names, looks like 'username' and 'password'.
So, try:

 

import requests
s= requests.session()
r = s.options('https://myaccount-api.genesisenergy.co.nz/api/authorize', data={'username':'MrX','password':'123'})
print(r.text)

I'm not with them so can't test.
It's quite odd to do an options request with data, so not sure if that's right.
But, without being a customer - I can't really see any requests after that.

Once you can mange to login, you will get the session cookie that you can then send with all other requests (request sessions will automatically do that).

 


Another great way to test without Python, is use Chrome Postman
https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en

That let's you build and send requests :)
Really good!

 

 

 

 

I had a quick toodle with that and got a 404, so I'll have to go through it again and see what i got wrong.  But it was handy all the same.  It's probalby going ot be in the too hard basket for me.  I've never really been able to get a scraping process to work, more got someone else to do it for me, unless it has a proper api with documentation.

 

 





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


nate
6473 posts

Uber Geek

Retired Mod
Trusted
Lifetime subscriber

  #1805328 22-Jun-2017 17:10
Send private message

(disclaimer: this is for Genesis business, I assume it's the same for their residential offering)

 

Do a POST to the following URL with the JSON below it:

 

https://myaccount-api.genesisenergy.co.nz/api/authorize

 

{"callerId":"username","autheticationSecret":"password","rememberMe":false,"sessionId":null}

 

This will give you back some more JSON which you'll need to grab the good stuff

 

{
"authenticated": true,
"identity": 1234,
"userName": "username",
"message": "Autheticated.",
"token": "ridiculouslylongstringofcharacters",
"expires": "2017-06-24T18:05:33.6611533+12:00",
"suspended": false
}

 

To get your usage, do a GET request (to https://myaccount-api.genesisenergy.co.nz/api/get-profile/default) with the token from above as an Authorization here, so:

 

authorization: Bearer ridiculouslylongstringofcharacters

 

This should give you a huge stack of JSON, which you'll need to parse to get the info out you want.

 

Enjoy!


davidcole

6037 posts

Uber Geek

Trusted

  #1805369 22-Jun-2017 18:51
Send private message

I did manage to cause them an object reference not found....oops - and now have to wait 10 mins after trying to login too many times.

 

I'm trying python rather than csharp.





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


 1 | 2 | 3
View this topic in a long page with up to 500 replies per page Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.