Answer the question
In order to leave comments, you need to log in
Unicode strings with encoding declaration are not supported - how can I fix it?
Tell a newbie about the code:
try:
url = 'http://autoconfig.' + domain + '/mail/config-v1.1.xml'
res = requests.get(url)
doc = etree.fromstring(res.text)
strpath = '//outgoingServer[@type="{}"]'.format('smtp')
a = doc.xpath(strpath)
elem = a[0].getchildren()
serv = elem[0].text
port = elem[1].text
return serv + ':' + port
except Exception as e:
print e
True
Answer the question
In order to leave comments, you need to log in
Try
doc = etree.fromstring(bytes(res.text, encoding='utf-8'))
print e
If not , then correctprint(e)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question