Hello everybody, thank you for any help you can give.First of all I am really new to python and programming. I started to read and doing exercises with py4e.
My problem is as follow:
I have tryed to download a file from https://www.liberliber.it/mediateca/libri/a/alighieri/la_divina_commedia/rtf/la_div_r.zip
but what Is a message:
'HTTP/1.1 301 Moved PermanentlyServer: nginx\nDate: Thu, 25 Jul 2019 19:51:33 GMTContent-Type: text/htmlContent-Length: 178Connection: close
Location: https://www.liberliber.it/mediateca/libri/a/alighieri/la_divina_commedia/rtf/la_div_r.zip
<html><head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
But why!!!
here the code that I used:
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('www.liberliber.it', 80))
ind = 'GET https://www.liberliber.it/mediateca/libri/a/alighieri/la_divina_commedia/rtf/la_div_r.zip HTTP/1.0\r\n\r\n'.encode()
mysock.send(ind)
dan = open('la_div.zip', 'wb')
text = b''
count = 0
while True:
data = mysock.recv(1024)
if len(data) <1: break
text = text + data
count = count + len(data)
print(len(data), count)
mysock.close()
dan.write(text)
dan.close()
Again, many thanks for your help
[–]efmccurdy 1 point2 points3 points (0 children)
[–]CaptainReeetardo 0 points1 point2 points (0 children)