Answer the question
In order to leave comments, you need to log in
urllib.urlopen and Russian URLs
Tell me, how can urllib'oy open Russian URLs?
All sorts of options:
urllib2.urlopen(u'http://my_site/method?¶m1=Русский текст'.encode('utf-8'))
either
or
do not help.
text = u'Русский текст c пробелом'
urllib2.urlopen(u'http://my_site/method?¶m1=%s' % text)
text = unicode(u'Русский текст c пробелом')
urllib2.urlopen(u'http://my_site/method?¶m1=%s' % text)
Answer the question
In order to leave comments, you need to log in
this was for parameters, and for domains you need to use punycode
'domain.rf'.encode('idna')
If I understood you correctly, then you are trying to open IRI as a URI, which is not entirely correct. There are many methods for translating from IRI. You can just use urllib.unquote(), but it doesn't always work. Therefore, we google for the request “python iri to uri” and copy the necessary code. There is a small method, I personally ripped from the Django framework (like django.utils.encoding.iri_to_uri)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question