Skip to content

Instantly share code, notes, and snippets.

@vortec
Created January 2, 2013 11:45
Show Gist options
  • Select an option

  • Save vortec/4434033 to your computer and use it in GitHub Desktop.

Select an option

Save vortec/4434033 to your computer and use it in GitHub Desktop.
# BeautifulSoup 3.2.0
>>> from BeautifulSoup import BeautifulSoup, CData
>>> s = BeautifulSoup("<div></div>")
>>> n = s.find('div')
>>> n.append(CData('<b>bleh</b>'))
>>> n
<div><![CDATA[<b>bleh</b>]]></div>
>>>
-------------
# BeautifulSoup 3.2.1
>>> from BeautifulSoup import BeautifulSoup, CData
>>> s = BeautifulSoup("<div></div>")
>>> n = s.find('div')
>>> n
<div></div>
>>> n.append(CData('<b>bleh</b>'))
>>> n
<div><![CDATA[&lt;b&gt;bleh&lt;/b&gt;]]></div>
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment