Skip to content

Commit

Permalink
try using lru cache
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoneerC committed Aug 14, 2024
1 parent 538a268 commit 2a434ed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
from functools import lru_cache

import httpx
from bs4 import BeautifulSoup
import requests
Expand Down Expand Up @@ -53,6 +55,7 @@ def extract_value(element, type_value):
raise ValueError(f"Failed to convert {type_value} value to float: {e}")


@lru_cache(maxsize=7)
def scrape_currency_website(currency_type, venta_index, compra_index):
main_url = "https://dolar-arg-app.netlify.app"
cache_value = r.get(currency_type.lower())
Expand Down Expand Up @@ -106,6 +109,7 @@ def scrape_currency_website(currency_type, venta_index, compra_index):
raise HTTPException(status_code=500, detail=f"Internal Server Error: {e}")


@lru_cache(maxsize=4)
def scrape_dolar_hoy(category):
url = f"https://dolarhoy.com/cotizacion-{category}"
cache_value = r.get(category)
Expand Down

0 comments on commit 2a434ed

Please sign in to comment.