python file downloader not working

Rahul Sircar devilsgrin94 at gmail.com
Tue Jul 25 13:01:11 EDT 2017


So I recently tried to write a script using urllib2 module.
Here is the code below:
import urllib2
file = 'metasploitable-linux-2.0.0.zip'
url='https://downloads.sourceforge.net/project/metasploitable/Metasploitable2/metasploitable-linux-2.0.0.zip'
response = urllib2.urlopen(url)
fh=open(file,'w')
fh.write(response.read())
fh.close()

I am getting this error in the output.
Traceback (most recent call last):
  File "urllib_read.py", line 6, in <module>
    fh.write(response.read())
  File "E:\Python27\lib\socket.py", line 355, in read
    data = self._sock.recv(rbufsize)
  File "E:\Python27\lib\httplib.py", line 597, in read
    s = self.fp.read(amt)
  File "E:\Python27\lib\socket.py", line 384, in read
    data = self._sock.recv(left)
  File "E:\Python27\lib\ssl.py", line 766, in recv
    return self.read(buflen)
  File "E:\Python27\lib\ssl.py", line 653, in read
    v = self._sslobj.read(len)
socket.error: [Errno 10053] An established connection was aborted by the software in your host machine.

Please someone help me out.



More information about the Python-list mailing list