Message193306
| Author |
vajrasky |
| Recipients |
LDTech, Mi.Zou, christian.heimes, ezio.melotti, orsenthil, terry.reedy, vajrasky |
| Date |
2013年07月18日.15:10:43 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1374160243.29.0.560739136632.issue17214@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I have no problem if this ticket is classified as "won't fix".
I am writing this for the confused souls who want to use urllib to access url containing non-ascii characters:
import urllib.request
from urllib.parse import quote
url = "http://www.libon.it/ricerca/7817940/3499155443/dettaglio/3102314/Onkel-Oswald-und-der-Sudan-Käfer/order/date_desc"
req = urllib.request.Request(url)
try:
req.selector.encode('ascii')
except UnicodeEncodeError:
req.selector = quote(req.selector)
response = urllib.request.urlopen(req, timeout=30)
the_page = response.read().decode('utf-8')
print(the_page) |
|