Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   urlretrieve a file whose name has spaces in it (http://www.velocityreviews.com/forums/t320273-urlretrieve-a-file-whose-name-has-spaces-in-it.html)

HP 07-29-2003 10:39 PM

urlretrieve a file whose name has spaces in it
 
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

Irmen de Jong 07-29-2003 10:57 PM

Re: urlretrieve a file whose name has spaces in it
 
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


Kevin Cazabon 07-31-2003 12:31 AM

Re: urlretrieve a file whose name has spaces in it
 
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:<10caf2e2.0307291439.33d9fcc3@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



All times are GMT. The time now is 08:47 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.