初学者求助
C:\Python27\python.exe C:/Users/wenfu/PycharmProjects/lian/baike_spider/spider_main.py
craw 1 : http://baike.baidu.com/item/Python
craw failed
craw 2 : http://baike.baidu.com/item/史记·2016?fr=navbar
Traceback (most recent call last):
File "C:/Users/wenfu/PycharmProjects/lian/baike_spider/spider_main.py", line 37, in <module>
obj_spider.craw(root_url)
File "C:/Users/wenfu/PycharmProjects/lian/baike_spider/spider_main.py", line 21, in craw
html_cont = self.downloader.download(new_url)
File "C:\Users\wenfu\PycharmProjects\lian\baike_spider\html_downloader.py", line 10, in download
response = urllib2.urlopen(url)
File "C:\Python27\lib\urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 404, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 422, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python27\lib\urllib2.py", line 1181, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
File "C:\Python27\lib\httplib.py", line 995, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 1029, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 991, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 844, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 820, in send
self.sock.sendall(data)
File "C:\Python27\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-12: ordinal not in range(128)
Process finished with exit code 1