import cgi
cgi.escape(posts).encode('ascii', 'xmlcharrefreplace')