N
NewFilmFan
I use Python 2.3 on Windows XP.
I wrote this program:
import httplib
conn = httplib.HTTPConnection("www.x.net")
conn.request("GET", "/x/y.jpg")
r1 = conn.getresponse()
print r1.status, r1.reason
data = r1.read()
datei = open('test.jpg','w')
datei.write(data)
datei.close()
It is almost a copy of the manual. Now I can establish the connection and
receive the data. (The first response from the server is 200, OK.) The jpg
file is 198 K. But it is not a valid jpeg file. When I download with my
browser, the file has the length 197K and it is valid, of course. Is this
a problem of writing text or binary data to a file? Can anybody help me?
TIA,
nff
I wrote this program:
import httplib
conn = httplib.HTTPConnection("www.x.net")
conn.request("GET", "/x/y.jpg")
r1 = conn.getresponse()
print r1.status, r1.reason
data = r1.read()
datei = open('test.jpg','w')
datei.write(data)
datei.close()
It is almost a copy of the manual. Now I can establish the connection and
receive the data. (The first response from the server is 200, OK.) The jpg
file is 198 K. But it is not a valid jpeg file. When I download with my
browser, the file has the length 197K and it is valid, of course. Is this
a problem of writing text or binary data to a file? Can anybody help me?
TIA,
nff