How to get HTML from a beautiful soup object

后端 未结 1 1707
梦谈多话
梦谈多话 2021-01-30 15:55

I have the following bs4 object listing:

>>> listing

.... >>> type(listing)

1条回答
  •  星月不相逢
    2021-01-30 16:29

    Just get the string representation:

    html_content = str(listing)
    

    This is a non-prettified version.

    If you want a prettified one, use prettify() method:

    html_content = listing.prettify()
    

    0 讨论(0)
提交回复
热议问题