Reputation: 165
I am using beautifulsoup to convert parse and edit an html. This works perfectly, but, when converting the soup object back to html with prettify(formatter="html"), it adds a lot of spaces and newlines that were not in the original html
What can i do to keep the original formatting?
Thanks
Upvotes: 2
Views: 1606
Reputation: 25048
Cause you create BeautifulSoup
object from a string a general approach would be to convert it back in this way. To get a more specific answer, please improve question and add details to clarify.
String to BeautifulSoup
object:
soup = BeautifulSoup(string)
BeautifulSoup
object to string:
str(soup)
Upvotes: 3