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

urlretrieve a file whose name has spaces in it

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.