resmed-scraper icon indicating copy to clipboard operation
resmed-scraper copied to clipboard

Example config?

Open Jay2645 opened this issue 4 years ago • 9 comments

Would it be possible to provide an example configuration file? Or at least instructions in the README -- I'm not 100% sure how to find viewstate or exist_token.

Jay2645 avatar Jul 08 '20 19:07 Jay2645

The exist_token comes from Exist's own API; you can get one here. I changed the script logic to not attempt to log in via Python anymore. Instead, I captured a login attempt from my browser as a curl command and have the script just run that curl and scrape its output. I've attached a screenshot of where to do so using Chrome; if you copy that command and paste it into a file named mycurl in the same directory as the script, it should work. Let me know if that doesn't do the trick. Screen Shot 2020-07-08 at 12 49 37 PM

handyman5 avatar Jul 08 '20 19:07 handyman5

Hi. I copied default aspx as cURL and created a empty config.json. but i still get errors "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" have i missed anything? mvh Fredrik Buchanan

fredrikbuchanan avatar Oct 14 '20 19:10 fredrikbuchanan

An empty file is not valid JSON, which is what that error is saying.

Here's an example config.json:

{
"viewstate": "",
"email": "",
"password": "",
"exist_token": "<your Exist API token per http://developer.exist.io/#requesting-a-token>"
}

The other empty lines are used by bits of code that are no longer active and I haven't bothered to clean them up since I switched to just running curl.

handyman5 avatar Oct 15 '20 17:10 handyman5

Ok. Cool will test it out. Thanks

fredrikbuchanan avatar Oct 15 '20 17:10 fredrikbuchanan

ok i have come a bit further but running in powershell i get: PS C:\Drift\myair> python .\scrape.py The command line is too long. Traceback (most recent call last): File "C:\Drift\myair\scrape.py", line 56, in scores_script = [x.renderContents() for x in scripts if 'myScores' in x.renderContents()][0] IndexError: list index out of range

if i try run it on a linux first resolve host and then typeerror: a bytes-like object is requiered, not 'str'

any tips on what could be wrong

fredrikbuchanan avatar Oct 16 '20 08:10 fredrikbuchanan

solved the linux problem so now i have list index out of range on both win and linux

fredrikbuchanan avatar Oct 16 '20 13:10 fredrikbuchanan

Is this script still working now ? Seems like Resmed has made some changes - I am not able to see the same structure as you while I try to copy the curl command ... The 'scripts' variable is populated with the JS file names for me, and I do not see a 'myScores' text in any of those JS files ...

badreamer avatar Jul 31 '21 18:07 badreamer

Same for me. Script seems broken it won't read myScores anymore.

Traceback (most recent call last): File "./scrape.py", line 56, in scores_script = [x.renderContents() for x in scripts if 'myScores' in x.renderContents()][0] IndexError: list index out of range

joverdijk avatar Aug 27 '21 19:08 joverdijk

myAir has re-built their US website and it works very differently.

For anyone who is interested: I have done a similar reverse-engineering of the new page, the code can be found here: https://github.com/prestomation/resmed_myair_sensors/blob/master/custom_components/resmed_myair/myair_client.py

that package is for integration into a home automation system called 'Home Assistant', but that client file will continue to be decoupled such that it can be used outside home assistant

prestomation avatar Jan 03 '22 23:01 prestomation