Add utils and multiple modifications on pypub
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Michel Roux 2021-04-11 18:02:29 +02:00
parent 2403fa2304
commit 9aa5b46a72
2 changed files with 14 additions and 0 deletions

View File

@ -44,6 +44,8 @@ for volume_tag in tags:
pagination.decompose()
for image in text.find_all('img'):
image.decompose()
for cut in text.find_all('hr'):
cut.decompose()
print(title)

12
utils.py Normal file
View File

@ -0,0 +1,12 @@
from bs4.element import NavigableString
def strip_content(tag):
# strip content from all children
children = [strip_content(child) for child in tag.children if not isinstance(child, NavigableString)]
# remove everything from the tag
tag.clear()
for child in children:
# Add back stripped children
tag.append(child)
return tag