Last active
October 18, 2016 18:13
-
-
Save Toyz/41cf5431dca7f4b6d5ef86fe40a753a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import time | |
previous = -1 | |
def main(): | |
while True: | |
GetData() | |
time.sleep(30) | |
def GetData(): | |
global previous | |
file = urllib2.urlopen("http://amomentincrime.s3.amazonaws.com/index.html").read() | |
splited = file.split("activos...") | |
value = splited[1].split("<br>")[0].strip() | |
diff = "N/A" | |
if previous == -1: | |
previous = float(value[:-1]) | |
else: | |
new_val = float(value[:-1]) | |
diff = new_val - previous | |
previous = new_val | |
diff = float("{0:.4f}".format(diff)) | |
diff = str(diff) | |
diff += "%" | |
print value + " - " + diff | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment