feat: replace request by builtin http
This commit is contained in:
parent
2760df07bd
commit
0f6f9b7dec
12
crypto
12
crypto
@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import requests
|
|
||||||
|
import http.client as http
|
||||||
|
|
||||||
# curl https://api.coingecko.com/api/v3/coins/list
|
# curl https://api.coingecko.com/api/v3/coins/list
|
||||||
COINS = [
|
COINS = [
|
||||||
@ -14,10 +15,15 @@ FORMAT = "{coin}=${price:.0f}"
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
coin_ids = ",".join([coin for coin in list(zip(*COINS))[0]])
|
coin_ids = ",".join([coin for coin in list(zip(*COINS))[0]])
|
||||||
url = f"https://api.coingecko.com/api/v3/simple/price?ids={coin_ids}&vs_currencies={CURRENCY}"
|
url = "api.coingecko.com"
|
||||||
|
path = f"/api/v3/simple/price?ids={coin_ids}&vs_currencies={CURRENCY}"
|
||||||
|
|
||||||
# {'bitcoin': {'usd': 69420}}
|
# {'bitcoin': {'usd': 69420}}
|
||||||
prices = json.loads(requests.get(url).text)
|
|
||||||
|
client = http.HTTPSConnection(url)
|
||||||
|
client.request("GET", path)
|
||||||
|
|
||||||
|
prices = json.loads(client.getresponse().read())
|
||||||
|
|
||||||
print(
|
print(
|
||||||
*[
|
*[
|
||||||
|
Loading…
Reference in New Issue
Block a user