From 0f6f9b7dec7e9a7a471493c93cf72621b7bd052b Mon Sep 17 00:00:00 2001 From: AngeD Date: Fri, 14 Jul 2023 18:00:02 +0200 Subject: [PATCH] feat: replace request by builtin http --- crypto | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crypto b/crypto index 8c36647..05a665d 100755 --- a/crypto +++ b/crypto @@ -1,7 +1,8 @@ #!/usr/bin/env python3 import json -import requests + +import http.client as http # curl https://api.coingecko.com/api/v3/coins/list COINS = [ @@ -14,10 +15,15 @@ FORMAT = "{coin}=${price:.0f}" def main(): 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}} - prices = json.loads(requests.get(url).text) + + client = http.HTTPSConnection(url) + client.request("GET", path) + + prices = json.loads(client.getresponse().read()) print( *[