Skip to content

Instantly share code, notes, and snippets.

@Toyz
Last active October 18, 2016 18:13
Show Gist options
  • Save Toyz/41cf5431dca7f4b6d5ef86fe40a753a7 to your computer and use it in GitHub Desktop.
Save Toyz/41cf5431dca7f4b6d5ef86fe40a753a7 to your computer and use it in GitHub Desktop.
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