File "***\parser.py", line 25, in getPageText return str(urlopen(url).readall()) File "C:\Python32\lib\urllib\request.py", line 138, in urlopen return opener.open(url, data, timeout) File "C:\Python32\lib\urllib\request.py", line 369, in open response = self._open(req, data) File "C:\Python32\lib\urllib\request.py", line 387, in _open '_open', req) File "C:\Python32\lib\urllib\request.py", line 347, in _call_chain result = func(*args) File "C:\Python32\lib\urllib\request.py", line 1156, in http_open return self.do_open(http.client.HTTPConnection, req) File "C:\Python32\lib\urllib\request.py", line 1136, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "C:\Python32\lib\http\client.py", line 964, in request self._send_request(method, url, body, headers) File "C:\Python32\lib\http\client.py", line 992, in _send_request self.putrequest(method, url, **skips) File "C:\Python32\lib\http\client.py", line 856, in putrequest self._output(request.encode('ascii')) UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-11: ordinal not in range(128)
response = urlopen() response.decode()
fata1exНе-а, проблема, судя по всему, при декодировании urlresponse = urlopen() response.decode()
File "***\parser.py", line 25, in getPageText return str(urlopen(url).decode()) File "C:\Python32\lib\urllib\request.py", line 138, in urlopen return opener.open(url, data, timeout) File "C:\Python32\lib\urllib\request.py", line 369, in open response = self._open(req, data) File "C:\Python32\lib\urllib\request.py", line 387, in _open '_open', req) File "C:\Python32\lib\urllib\request.py", line 347, in _call_chain result = func(*args) File "C:\Python32\lib\urllib\request.py", line 1156, in http_open return self.do_open(http.client.HTTPConnection, req) File "C:\Python32\lib\urllib\request.py", line 1136, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "C:\Python32\lib\http\client.py", line 964, in request self._send_request(method, url, body, headers) File "C:\Python32\lib\http\client.py", line 992, in _send_request self.putrequest(method, url, **skips) File "C:\Python32\lib\http\client.py", line 856, in putrequest self._output(request.encode('ascii')) UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-11: ordinal not in range(128)
>>>page=getPageText("***/Опт".encode("ascii")) Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> page=getPageText("***/Опт".encode("ascii")) UnicodeEncodeError: 'ascii' codec can't encode characters in position 30-36: ordinal not in range(128)
fata1exНе сразу приметил, спасибо, оно.response = urlopen() response.decode()
Или у вас в урле юникод? Тогда http://python.su/forum/topic/6750/