Skip to content

Instantly share code, notes, and snippets.

@rsieiro
Created June 5, 2020 15:42
Show Gist options
  • Save rsieiro/71fe2f8799f8e90c13fd50bd71110346 to your computer and use it in GitHub Desktop.
Save rsieiro/71fe2f8799f8e90c13fd50bd71110346 to your computer and use it in GitHub Desktop.
Dólar Comercial - BitBar Plugin
#!/usr/bin/env LC_ALL=en_US.UTF-8 /usr/bin/python3
#
# <bitbar.title>Dólar Comercial</bitbar.title>
# <bitbar.version>1.0</bitbar.version>
# <bitbar.author>Rodrigo Sieiro</bitbar.author>
# <bitbar.author.github>rsieiro</bitbar.author.github>
# <bitbar.dependencies>python</bitbar.dependencies>
import urllib.request
import json
url = "http://economia.awesomeapi.com.br/json/all/USD-BRL"
result = urllib.request.urlopen(url).read()
json = json.loads(result)
value = json["USD"]
print(value["code"] + ": " + value["ask"])
print("---")
print(value["name"])
print(value["create_date"])
print("---")
print("Venda: " + value["ask"] + " (" + value["pctChange"] + "%)")
print("Compra: " + value["bid"])
print("Máxima: " + value["high"])
print("Mínima: " + value["low"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment