Meilleure gestion des SIRET absents du SIRENE dans acheteur et titulaire

This commit is contained in:
Colin Maudry
2026-02-05 14:18:38 +01:00
parent cb885eeb90
commit 64fc40e5aa
3 changed files with 77 additions and 68 deletions
+8 -3
View File
@@ -9,7 +9,7 @@ import dash
import polars as pl
import polars.selectors as cs
from dash import no_update
from httpx import get, post
from httpx import HTTPError, get, post
from polars.exceptions import ComputeError
from unidecode import unidecode
@@ -208,8 +208,13 @@ def format_values(dff: pl.DataFrame) -> pl.DataFrame:
def get_annuaire_data(siret: str) -> dict:
url = f"https://recherche-entreprises.api.gouv.fr/search?q={siret}"
response = get(url)
return response.json()["results"][0]
try:
response = get(url).raise_for_status()
response = response.json()["results"][0]
except (HTTPError, IndexError):
response = None
logger.warning("Could not fetch data from recherche-entreprises.api.")
return response
def get_decp_data() -> pl.DataFrame: