473,486 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Downloading images with python

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
1 1188
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2113
by: Marc | last post by:
Hello, I have a page with lots of thumbnails of photos. I want the user to be able to dload a big version of the photo (also present on the server) by either 1) clicking on it (left...
4
2147
by: Luke StClair | last post by:
Only marginally belonging in this newsgroup... but oh well. I've just started writing in python, and I want to make the files available on the web. So I did the standard <a...
23
1785
by: Doug van Vianen | last post by:
Hi, Is there some way in JavaScript to stop the downloading of pictures from a web page? Thank you. Doug van Vianen
6
5798
by: justsee | last post by:
Hi, I'm using Python 2.3 on Windows for the first time, and am doing something wrong in using urllib to retrieve images from urls embedded in a csv file. If I explicitly specify a url and image...
4
8625
by: aldonnelley | last post by:
Hi there: a bit of a left-field question, I think. I'm writing a program that analyses image files downloaded with a basic crawler, and it's slow, mainly because I only want to analyse files...
5
1738
by: OBAFGKM_RNS | last post by:
I have a javascript timer on my page that counts to 10. Every half second it alternates images on my buttons from a lighter image to a darker image, giving the appearance of the buttons blinking....
4
1602
by: surja | last post by:
Hi, I have written a code to download images from a server end desktop, but while running the code ,WTK is showing a runtime error " Create image from Byte array Uncaught exception...
6
1375
by: dysfunct | last post by:
Question: If I have a lot of <imgtags on a site, all linking from all sorts of domains, is there a way to check to see which ones have finished downloading and which ones haven't? For example let's...
1
1268
YarrOfDoom
by: YarrOfDoom | last post by:
I'm trying to create a script to download a series of images for me, problem is that I have no idea on how to actually get them from the internet to my computer. I've been thinking this: import...
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.