ajout(main.py): optimisation des fonctions

This commit is contained in:
2026-02-11 23:46:22 +01:00
parent 96dbaaaaf6
commit 011bb6a689
3 changed files with 8 additions and 35 deletions

0
donnee.csv Normal file
View File

14
main.py
View File

@@ -113,7 +113,7 @@ class _ScraperData:
return None return None
val = cast(str, app_dict.get("value")).rstrip("+").split("-") val = cast(str, app_dict.get("value")).rstrip("+").split("-")
if len(val) > 1: if len(val) > 1 and val[1] != "":
val[0] = str((int(val[0]) + int(val[1])) / 2) val[0] = str((int(val[0]) + int(val[1])) / 2)
return val[0] return val[0]
@@ -301,10 +301,13 @@ class Scraper:
def getvins(self, subdir: str): def getvins(self, subdir: str):
cache: set[str] = set[str]() cache: set[str] = set[str]()
page = 0
for page in range(1, 64): while True:
page += 1
products_list = self._geturlproductslist(f"{subdir}?page={page}") products_list = self._geturlproductslist(f"{subdir}?page={page}")
print(f"---- {page} ----")
if not products_list: if not products_list:
break break
@@ -314,10 +317,7 @@ class Scraper:
link = product.get("seoKeyword") link = product.get("seoKeyword")
if not link: if link and link not in cache:
continue
if link not in cache:
try: try:
infos = self.getjsondata(link).informations() infos = self.getjsondata(link).informations()
print(infos) print(infos)
@@ -326,4 +326,4 @@ class Scraper:
print(f"Erreur sur le produit {link}: {e}") print(f"Erreur sur le produit {link}: {e}")
print(Scraper().getvins("bordeaux.html")) # Scraper().getvins("bordeaux.html")

View File

@@ -1,27 +0,0 @@
Haut-Médoc,None,None,90,16.1
Haut-Médoc,90.0,16,None,23.2
Haut-Médoc,None,None,None,14.2
Saint-Estèphe,93,17,96,59.0
Pessac-Léognan,90,16.5,94,36.0
Pessac-Léognan,89,16.5,95,39.2
Haut-Médoc,89.0,15,92,26.8
Haut-Médoc,92,16.5,93,65.4
Margaux,92,16,93,64.3
Moulis,92,15.5,93,41.4
Haut-Médoc,None,None,None,15.2
Pauillac,97,18,98,298.0
Saint-Emilion,95,15,96,106.4
Haut-Médoc,92,16,95,32.7
Pomerol,88,16,96,92.7
Pessac-Léognan,90,16.5,93,33.1
Haut-Médoc,89,14.5,None,18.8
Haut-Médoc,93.0,16,94,56.3
Pessac-Léognan,86,None,92,31.6
Haut-Médoc,89,16,92,25.1
Haut-Médoc,92,16,94.5,68.7
Saint-Estèphe,91.0,None,91.5,27.3
Pomerol,94,16.5,95,97.5
Margaux,93,16,95,54.5
Pessac-Léognan,93,16.5,93,46.9
Saint-Estèphe,92,16,96,50.1
Pessac-Léognan,93,16.5,94,60.9