How to get HTML from a beautiful soup object

后端 未结 1 1705
梦谈多话
梦谈多话 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)
提交回复
热议问题