Problem with downloading from www

NewFilmFan gg at yahoo.com
Tue Apr 12 02:22:17 EDT 2005


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


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----



More information about the Python-list mailing list