Convert
to end line

前端 未结 6 1819
别跟我提以往
别跟我提以往 2020-12-08 19:00

I\'m trying to extract some text using BeautifulSoup. I\'m using get_text() function for this purpose.

My problem is that the text contain

6条回答
  •  庸人自扰
    2020-12-08 19:46

    Instead of replacing the tags with \n, it may be better to just add a \n to the end of all of the tags that matter.

    To steal the list from @petezurich:

    for elem in soup.find_all(["a", "p", "div", "h3", "br"]):
        elem.append('\n')
    

提交回复
热议问题