feat(convert): amélioration des nettoyages de logo
This commit is contained in:
parent
3dc21e7b94
commit
71300113fe
@ -75,8 +75,9 @@ def fetch_and_remove_logo(article, force_download):
|
||||
for elem in list(img.previous_siblings) + list(img.next_siblings)
|
||||
if elem != '\n'
|
||||
]
|
||||
if img.parent.name == 'a' and not has_siblings:
|
||||
img = img.parent
|
||||
if img.parent.name in ['a', 'p'] and not has_siblings:
|
||||
img.parent.replace_with('')
|
||||
else:
|
||||
img.replace_with('')
|
||||
|
||||
soup = bs(article.descriptif, 'html.parser')
|
||||
@ -91,6 +92,15 @@ def fetch_and_remove_logo(article, force_download):
|
||||
fetch_logo(src)
|
||||
remove_img(img)
|
||||
article.descriptif = str(soup)
|
||||
|
||||
# L'image est généralement reprise dans le corps avec un format
|
||||
# différent (par ex sans lien vers l'article).
|
||||
soup = bs(article.texte, 'html.parser')
|
||||
img = soup.find('img', src=src)
|
||||
if img:
|
||||
remove_img(img)
|
||||
article.texte = str(soup)
|
||||
|
||||
article.save()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user