How can i grab CData out of BeautifulSoup

后端 未结 5 1188
春和景丽
春和景丽 2020-12-03 12:16

I have a website that I\'m scraping that has a similar structure the following. I\'d like to be able to grab the info out of the CData block.

I\'m using BeautifulSo

5条回答
  •  -上瘾入骨i
    2020-12-03 13:17

    import re
    from bs4 import BeautifulSoup
    
    soup = BeautifulSoup(content)
    for x in soup.find_all('item'):
        print re.sub('[\[CDATA\]]', '', x.string)
    

提交回复
热议问题