Created
June 5, 2020 15:42
-
-
Save rsieiro/71fe2f8799f8e90c13fd50bd71110346 to your computer and use it in GitHub Desktop.
Dólar Comercial - BitBar Plugin
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
#!/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