how to remove text between [removed] and [removed] using python?

后端 未结 9 647
眼角桃花
眼角桃花 2021-02-04 19:19

how to remove text between using python?

9条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 20:21

    You can use BeautifulSoup with this (and other) methods:

    soup = BeautifulSoup(source.lower())
    to_extract = soup.findAll('script')
    for item in to_extract:
        item.extract()
    

    This actually removes the nodes from the HTML. If you wanted to leave the empty tags you'll have to work with the item attributes rather than just extracting it from the soup.

提交回复
热议问题