[newbie] Preserving carriage returns when calling soup.body.text?
10 Feb
2023
10 Feb
'23
4:05 p.m.
Hello, I can't find how to tell lxml/BS to preserve carriage returns in an HTML snippet when calling soup.body.text: After removing </br>'s, it also removes the CRLF that follows. ========== builder = LXMLTreeBuilderForXML(preserve_whitespace_tags=["body"]) rows = cur.fetchall() for row in rows: #BAD soup = BeautifulSoup(row["introtext"], builder=builder,features='lxml') soup = BeautifulSoup(row["intro"],features='lxml') print(soup.body.text) break ========== Is there an option? Thank you.
10 Feb
10 Feb
7:24 p.m.
My mistake, I'm sorry. All the carriage returns were stripped in the input file. BS/lxml weren't to blame. Problem solved.
440
Age (days ago)
440
Last active (days ago)
1 comments
1 participants
participants (1)
-
codecomplete@free.fr