Bentham commited on
Commit
352dced
·
verified ·
1 Parent(s): a367536

nouveau debug google

Browse files
Files changed (1) hide show
  1. main.py +2 -18
main.py CHANGED
@@ -406,11 +406,11 @@ async def clean_html_content(html_content: str, image_counter: List[int], images
406
  images_data[f"IMG_{X}"] = {
407
  'base64_image': base64_image
408
  }
409
- # Création d'un véritable nœud de commentaire
410
  comment_tag = Comment(f"IMG_{X}")
411
  img.insert_before(comment_tag)
412
  logging.debug(f"DEBUG CLEAN_HTML: Insertion du commentaire avant l'image : {comment_tag}")
413
- img.decompose() # Supprimer la balise img
 
414
  logging.debug(f"DEBUG CLEAN_HTML: Suppression de la balise img.")
415
  image_counter[0] += 1
416
  else:
@@ -422,22 +422,6 @@ async def clean_html_content(html_content: str, image_counter: List[int], images
422
  else:
423
  logging.debug("DEBUG CLEAN_HTML: Aucune balise <img> trouvée dans le contenu HTML.")
424
 
425
- # Vérifiez que les commentaires sont bien insérés
426
- logging.debug(f"DEBUG CLEAN_HTML: HTML après insertion des commentaires IMG_X : {str(soup)}...")
427
-
428
- for img in soup.find_all('img'):
429
- img.decompose()
430
-
431
- scripts_to_remove = soup.find_all('script', src=True)
432
- for script in scripts_to_remove:
433
- src = script['src']
434
- if src.startswith('https://bentham-converttohtml.hf.space/'):
435
- script.decompose()
436
-
437
- for tag in soup.find_all('p'):
438
- if not tag.get_text(strip=True):
439
- tag.decompose()
440
-
441
  logging.debug(f"DEBUG CLEAN_HTML: Fin de clean_html_content")
442
  return str(soup)
443
 
 
406
  images_data[f"IMG_{X}"] = {
407
  'base64_image': base64_image
408
  }
 
409
  comment_tag = Comment(f"IMG_{X}")
410
  img.insert_before(comment_tag)
411
  logging.debug(f"DEBUG CLEAN_HTML: Insertion du commentaire avant l'image : {comment_tag}")
412
+ logging.debug(f"DEBUG CLEAN_HTML: Vérification immédiate du commentaire après insertion : {soup.find(string=comment_tag)}")
413
+ img.decompose()
414
  logging.debug(f"DEBUG CLEAN_HTML: Suppression de la balise img.")
415
  image_counter[0] += 1
416
  else:
 
422
  else:
423
  logging.debug("DEBUG CLEAN_HTML: Aucune balise <img> trouvée dans le contenu HTML.")
424
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
  logging.debug(f"DEBUG CLEAN_HTML: Fin de clean_html_content")
426
  return str(soup)
427