I have this code:
import requests
from xml.dom.minidom import parseString
site = 'test.com'
r = requests.get('http://bar-navig.yandex.ru/u?ver=2&url=http://%s&show=1' % (site))
#print r.text.encode('utf-8')
xmldoc = parseString(r.text.encode('utf-8'))
print xmldoc.getElementsByTagName('tcy')[0].attributes['value'].value
So, it works, but if I have in site, for example, 'vk.com' or 'google.ru', I have an error: xml.parsers.expat.ExpatError: not well-formed (invalid token).
How to fix it? Thanks.