Make bs4 only replace the tag name instead of name and contents
This commit is contained in:
parent
d07d49d42e
commit
27f61c4374
|
@ -68,10 +68,10 @@ def extract_toot(toot):
|
|||
toot = html.unescape(toot) # convert HTML escape codes to text
|
||||
soup = BeautifulSoup(toot, "html.parser")
|
||||
for lb in soup.select("br"): # replace <br> with linebreak
|
||||
lb.replace_with("\n")
|
||||
lb.name = "\n"
|
||||
|
||||
for p in soup.select("p"): # ditto for <p>
|
||||
p.replace_with("\n")
|
||||
p.name = "\n"
|
||||
|
||||
for ht in soup.select("a.hashtag"): # convert hashtags from links to text
|
||||
ht.unwrap()
|
||||
|
|
Loading…
Reference in New Issue