关于Python爬虫 403的错误
错误提示:Traceback(mostrecentcalllast):File"C:\Users\admin\Desktop\new1.py",line7,in<modu...
错误提示:
Traceback (most recent call last):
File "C:\Users\admin\Desktop\new1.py", line 7, in <module>
response=urllib.request.urlopen(url,timeout=10)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 156, in urlopen
return opener.open(url, data, timeout)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 469, in open
response = self._open(req, data)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 487, in _open
'_open', req)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 447, in _call_chain
result = func(*args)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 1274, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 1253, in do_open
r = h.getresponse()
File "D:\Program Files\Python 3.3.5\lib\http\client.py", line 1147, in getresponse
response.begin()
File "D:\Program Files\Python 3.3.5\lib\http\client.py", line 358, in begin
version, status, reason = self._read_status()
File "D:\Program Files\Python 3.3.5\lib\http\client.py", line 320, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "D:\Program Files\Python 3.3.5\lib\socket.py", line 297, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
添加了Header 展开
Traceback (most recent call last):
File "C:\Users\admin\Desktop\new1.py", line 7, in <module>
response=urllib.request.urlopen(url,timeout=10)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 156, in urlopen
return opener.open(url, data, timeout)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 469, in open
response = self._open(req, data)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 487, in _open
'_open', req)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 447, in _call_chain
result = func(*args)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 1274, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "D:\Program Files\Python 3.3.5\lib\urllib\request.py", line 1253, in do_open
r = h.getresponse()
File "D:\Program Files\Python 3.3.5\lib\http\client.py", line 1147, in getresponse
response.begin()
File "D:\Program Files\Python 3.3.5\lib\http\client.py", line 358, in begin
version, status, reason = self._read_status()
File "D:\Program Files\Python 3.3.5\lib\http\client.py", line 320, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "D:\Program Files\Python 3.3.5\lib\socket.py", line 297, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
添加了Header 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询