Add utils and multiple modifications on pypub
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2403fa2304
commit
9aa5b46a72
@ -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
12
utils.py
Normal 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
|
Reference in New Issue
Block a user