在自己的网站中(基于tornado),如果URL中含有中文,没有urlencode的话,搜索引擎爬过来会出现decode的异常:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe5 in position 6: invalid continuation byte
如果是urlencode过的便可以正常解析。但是,我发现豆瓣的tag好多也都是没有urlencode的URL(如下图),请问这样不会出现问题吗?

可以在nginx上做统一转换吗?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
把代码的编码格式换成utf8试试
如果使用urllib2,可以用下面的方法进行encode
urllib2.quote(s.encode("utf-8"))