473,851 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to download a file from an HTTP server given the URL?

Hopefully a simple question: how do I download a file (jpg image) to my
hard drive from a website assuming I have its (the image's) URL? I
tried urllib.urlretri eve() and it's not working. I'm relatively new to
Python, so I'm probably make a dumb mistake or looking in the wrong place.

Any help would be appreciated.

Thanks,

J. W. McCall
Jul 18 '05 #1
6 1635
Ok, update: I got it to work downloading to the default temp directory
with default temp names using urllib.urlretri eve(). If I try to specify
the path and filename, if says that the file doesn't exist. I don't see
why it doesn't just create that file.

Thanks,

J. W. McCall
Jul 18 '05 #2
J. W. McCall wrote:
Ok, update: I got it to work downloading to the default temp directory
with default temp names using urllib.urlretri eve(). If I try to specify
the path and filename, if says that the file doesn't exist. I don't see
why it doesn't just create that file.


Also try to give examples of real code when asking questions like this.
What path and filename, etc? Show snippets that you typed at the
interactive prompt and cut and paste (not retyped!) directly into the
message. Also specify your platform and the version of Python you are
using, and any other critical info you can think of. We're not
mind-readers**.

-Peter

** Well, some people here are, but they've already read your mind and
concluded that you will find the answer on your own, given enough time,
so they aren't wasting their valuable time helping you. Bastards. :-)
Jul 18 '05 #3
This sample run Ok on my windows :
def recupfileweb(ad r, repenregistreme nt):
data = urllib.urlopen( adr).read()
list = string.split(ad r,'/')
nomlocal=list[-1]
f = open(repenregis trement+nomloca l, "wb")
f.write(data)
f.close()
print('Fichier '+repenregistre ment+nomlocal+' téléchargé depuis '+adr)
recupfileweb("h ttp://ponx.org/downloads/toto.zip","c:\\ rdest\\") #==>
C:\rdest\toto.z ip



--
@-salutations
--
Michel Claveau
mél : http://cerbermail.com/?6J1TthIa8B
sites : http://mclaveau.com http://bergoiata.org http://ponx.org


Jul 18 '05 #4
Hi Peter,

You are right. But why being so rude?

Have you never been a newbie somewhere asking dumb question badly?

I don't understand that...

- Sylvain

Peter Hansen wrote:
J. W. McCall wrote:
Ok, update: I got it to work downloading to the default temp directory
with default temp names using urllib.urlretri eve(). If I try to
specify the path and filename, if says that the file doesn't exist. I
don't see why it doesn't just create that file.

Also try to give examples of real code when asking questions like this.
What path and filename, etc? Show snippets that you typed at the
interactive prompt and cut and paste (not retyped!) directly into the
message. Also specify your platform and the version of Python you are
using, and any other critical info you can think of. We're not
mind-readers**.

-Peter

** Well, some people here are, but they've already read your mind and
concluded that you will find the answer on your own, given enough time,
so they aren't wasting their valuable time helping you. Bastards. :-)

Jul 18 '05 #5
Sylvain Hellegouarch wrote:
Hi Peter,

You are right. But why being so rude?
"Rude" by what definition? If you mean I was being "uncivil",
I disagree. If you mean my reply was "unpolished " or "coarse"
(maybe "blunt"?), then I can't argue with that. But you
wouldn't have posted if you thought I had merely not taken
the time to prepare a more refined wording for delicate
ears, so you must have meant something like "uncivil".

So I was not being rude. I was being helpful, in a blunt way.
I said nothing offensive, or at least not intentionally.
I asked the OP to give more info, and I added a bit of
coarse humour as well. Perhaps you were looking for offense where
none was intended...
Have you never been a newbie somewhere asking dumb question badly?
No doubt, a long time ago, but it makes no difference to whether
or not I try to help people help themselves. By showing some
newbies how to ask better questions, I not only help them, but I
reduce the burden on those of us who try to provide support in this
forum.
I don't understand that...
Re-read my posting without looking for offense, and maybe you
will. (Note: nothing in _this_ posting was intended to offend
either. Just for reference.)

-Peter
- Sylvain

Peter Hansen wrote:
J. W. McCall wrote:
Ok, update: I got it to work downloading to the default temp
directory with default temp names using urllib.urlretri eve(). If I
try to specify the path and filename, if says that the file doesn't
exist. I don't see why it doesn't just create that file.


Also try to give examples of real code when asking questions like this.
What path and filename, etc? Show snippets that you typed at the
interactive prompt and cut and paste (not retyped!) directly into the
message. Also specify your platform and the version of Python you are
using, and any other critical info you can think of. We're not
mind-readers**.

-Peter

** Well, some people here are, but they've already read your mind and
concluded that you will find the answer on your own, given enough time,
so they aren't wasting their valuable time helping you. Bastards. :-)

Jul 18 '05 #6
Sylvain Hellegouarch <sh@defuze.or g> writes:
Peter Hansen wrote: [...] Hi Peter,

You are right. But why being so rude?

[...]

Can't see any trace of rudeness in Peter's message.
John
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8823
by: Aardwolf | last post by:
I've had PHP on my Win2K server running IIs 5 for about 2 weeks now. I have an annoying problem in that I can not run the php scripts/pages locally, instead they open up in the browser as a download. By that I mean that If I access them via my lan or the net from another computer on my lan, the webpages that have php on them and end in a .php extension all run fine and work just great. BUT if I open up the browser on the IIs server...
6
3765
by: Bryan Martin | last post by:
Ok im trying to figure out how internet explorers file download box always seem to at least come close to knowing the exact file size/time to download. From what I can tell its getting its not getting its info from the content-length. I know this because I can test query against a apache box that does not return the content length however IE still knows the size of the files. What am i missing? Bryan
4
468
by: Frasse | last post by:
Hello all! If a client has run a program with url like this: http://server/HelloWorld.exe, then the assembly HelloWorld.exe will be cached in Assembly's Download Cache. But if then a new version of HelloWorld.EXE is deployed on server, the client will experience a crash until he/she clears the assembly's download cache (at least on this machine...) is it possible to make a client to automatically delete its cached
1
2724
by: rdemyan via AccessMonster.com | last post by:
My App has 10 or so tables that we provide that contains proprietary data. This data will need to be updated once or twice a year. I would like some comments, suggestions on my proposed strategy for updating these tables via an ftp site: 1) Post a .mdb file to our ftp web site that contains the updated tables. My App code connects to the ftp site and gets the file name for any update files on the site. I already have code to do this...
13
3333
by: bmurphy | last post by:
Last week after much searching, I found the answer to my problem in this newsgroup. I can't find the thread from which I got my solution, but I wanted to report back what worked. When the site visitor fills out the form and submits it, this calls a rather ordinary asp script like formmail.asp that sends the emails and displays a "thank you" web page. At the very end of my "thank you" web page I placed the following: <script...
12
2852
by: comp.lang.php | last post by:
index.php: // STUFF // STEP 1: imagecreatetruecolor ONLY IF GD 2.0+ SUPPORTED AND FOUND if ($this->isSuccessful && !$hasMogrified && $image && !$newImage && function_exists('imagecreatetruecolor') && preg_match('/2\.0/i', $this->gd_info_array)) { $newImage = @imagecreatetruecolor($configArray, $configArray);
2
6983
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
2
1745
by: jwf | last post by:
I am developming a web application in ASP.NET (VB) and am looking to develop functionality where a user clicks on a link to download a file but at no point can the user see the actual URL link to the file. When the file is originally uploaded to the webserver it will be given a unique random filename and the link to the file + description sill be stored in sql server. Basically the system must be secure so that a user MUST go through...
1
47511
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
9896
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11017
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10670
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10352
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9505
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5736
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5933
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4548
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4143
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.