By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,441 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,441 IT Pros & Developers. It's quick & easy.

Downloading images with python

P: n/a
On 23. of October last year a the follwing was posted to this group:
htmlSource=urllib.urlopen("http://www.godandscience.org/images/nebula.jpg")
# Read from the object, storing the page's contents in 's'.
s = htmlSource.read()
htmlSource.close()
myfile = open("myfile.jpg", "w")
myfile.write(s)
myfile.close
There were two advices (use urllib2 and "wb"). I tried to build this
script on this basis:

import win32api
import win32com
import urllib2
gif&p=TAMA&fy=1900&ty=2005&m=21&r_type=TR&r_no=1")
htmlSource=urllib2.urlopen("http://www.godandscience.org/images/nebula..jpg")
# Read from the object, storing the page's contents in 's'.
s = htmlSource.read()
htmlSource.close()
myfile = open("P:\Jobb\Prosjekt\Maanedsoversikt\myfile.jpg" , "wb")
myfile.write(s)
myfile.close
But the images get cropped at the bottom. Any suggestions on how to get
the whole image, and not only 80 - 90% (I run python 2.4 with PythonWin on
a Windows XP)

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hans Olav Hygen wrote:
myfile = open("P:\Jobb\Prosjekt\Maanedsoversikt\myfile.jpg" , "wb")
myfile.write(s)
myfile.close
make that "myfile.close()"
But the images get cropped at the bottom.
files are closed when the program exits (unless it does so in an uncontrolled way),
so I assume you were trying to access the file while your script was still running.

</F>

Oct 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.