Page 2 of 2

Re: Converting AppleScript that reads data from remote URL

PostPosted: Mon Jun 29, 2020 1:59 pm
by FlyingDiver
Yeah, the strings in that HTML are wonky to parse. This works:

Code: Select all
import requests

# output from gmcmap.com looks like this:
# {"time": "2019-08-04 10:44:53", "CPM": "19", "ACPM": "18.22", "uSv": "0.12"}

result = requests.get("http://www.gmcmap.com/historyData-plain.asp?Param_ID=68108722812")
lines = result.text.split(',')
words = lines[1].split(":")
cpm_value = words[1].replace('"','').replace(' ','')
indigo.variable.updateValue(385534937, cpm_value)


That gets rid of all the double-quotes and the space that's in the string.

Re: Converting AppleScript that reads data from remote URL

PostPosted: Mon Jun 29, 2020 2:04 pm
by gmusser
Hooray, it works! And I learned a bit more about Python. Thanks again.