473,287 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

urlretrieve a file whose name has spaces in it

HP
I am using urllib.urlretrieve() to download a file from a web site.
THe trouble is that the file name has spaces in it,
such as "string string1 foo.doc".

The statement:
urllib.urlretrieve("http://website.com/path/string string1 foo.doc",
"local_file");

produces local_file which contains the following one line:
<html><head><title>Error</title></head><body>The parameter is
incorrect. </body></html>

What is the correct way of specifying the this file in urlretrieve() ?

thanks
HP
Jul 18 '05 #1
2 6858
HP wrote:
urllib.urlretrieve("http://website.com/path/string string1 foo.doc",
"local_file");


Try

urllib.urlretrieve(urllib.quote("http://website.com/path/string string1 foo.doc"), "local_file")

instead.

And what is the semicolon doing there? ;-)

--Irmen

Jul 18 '05 #2
You can easily escape spaces with "%20"

as in:
urllib.urlretrieve("http://website.com/path/string string1
foo.doc".replace(" ", "%20"), "local_file")

hp@rentec.com (HP) wrote in message news:<10**************************@posting.google. com>...
I am using urllib.urlretrieve() to download a file from a web site.
THe trouble is that the file name has spaces in it,
such as "string string1 foo.doc".

The statement:
urllib.urlretrieve("http://website.com/path/string string1 foo.doc",
"local_file");

produces local_file which contains the following one line:
<html><head><title>Error</title></head><body>The parameter is
incorrect. </body></html>

What is the correct way of specifying the this file in urlretrieve() ?

thanks
HP

Jul 18 '05 #3

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

Similar topics

2
by: Sam Sungshik Kong | last post by:
Hello! I'm trying to download PDF files from web to my computer using urllib. Some pdf files are fine but other files are downloaded only 6kB which is wrong. It didn't show any error message. ...
1
by: Josh | last post by:
Hi. I am writing a script that downloads lots of zips from a usgs site. All is going well except that occasionally, in the midst of downloading a file, the script just hangs and i must either...
0
by: Ray Slakinski | last post by:
I got a small issue, I am using urllib.urlretreive to download files but in some cases I'm downloading from a CGI that is redirecting urlretrieve to a different url. Example: ...
1
by: Rene Lopez | last post by:
I'm building an app that needs to download a file from the web. I'm trying to make sure I catch any issues with the download but I've run into a problem. here's what I have so far: try:...
6
by: Sven | last post by:
Hi guys and gals, I'm wrestling with the urlretrieve function in the urllib module. I want to download a file from a web server and save it locally with the same name. The problem is the URL -...
7
by: ianenis.tiryaki | last post by:
well i got this assignment which i dont even have a clue what i am supposed to do. it is about reading me data from the file and load them into a parallel array here is the question: Step (1) ...
1
by: silverburgh.meryl | last post by:
Hi, I use urlretrieve to retrieve resources from a http server. Can you please tell me how can I get the HTTP error (whenever happens)? And what kind of different exception urlretrieve will...
1
by: Abandoned | last post by:
Hi.. I want to set 30 second urllib.urlretrieve timeout.. Because if urllib.urlretrieve can't connect to page wait 1-2 hour... I download the images to my server with urlretrieve if you know the...
0
by: triplezone3 | last post by:
I have looked in to urllib2, and I can't find a function which would allow me to get the progress of the download as it happens, bit by bit, like urlretrieve does, at least not easily....
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.