While working with json in python, I've written this small script to fetch the current price of BTC. This works fine when I run the script in Ubuntu terminal.
What I want is to update the variable current_price
for every minute so that I can use this variable to display a desktop notification for current price.
I was looking for cron
to schedule the task but It'll not work because I want to run the script after each minute, not at a specific time.
what is the best practice to achieve this?
import urllib, json
url = "https://koinex.in/api/ticker"
response = urllib.urlopen(url)
data = json.loads(response.read())
current_price = data["prices"]["BTC"]
print current_price