Downloading images with python
Hans Olav Hygen
hhygen at fjerndette.start.no
Fri Oct 20 03:33:15 EDT 2006
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/
More information about the Python-list
mailing list