Hi, I've recently installed Micropython 1.9.3 onto a NodeMCU device, and I'm currently trying to get a Python file I've previously written for a Raspberry Pi to run. I've imported urllib.urequest and successfully ran
f = urllib.urequest.urlopen("
http://aurorawatch.lancs.ac.uk/api/0.1/activity.txt"), however, I don't know how to then manipulate the downloaded string. In Python I would use lines = f.readlines() but this results in an error:-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'socket' object has no attribute 'readlines'
Can you please advise how I can manipulate the text string downloaded from the above site?
Thanks,
Andrew
UPDATE: I've discovered the following:-
import urequests as requests
f = requests.get("
http://aurorawatch.lancs.ac.uk/api/0.1/activity.txt")
myfile = (f.text)
print (myfile)
f.close()
will save the contents of the above txt file to "myfile", now I need to figure out how to manipulate myfile so that just the final numerical value of the last line is extracted...