urlretrieve a file whose name has spaces in it

Kevin Cazabon kevin at cazabon.com
Wed Jul 30 20:31:27 EDT 2003


You can easily escape spaces with "%20"

as in:


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



hp at rentec.com (HP) wrote in message news:<10caf2e2.0307291439.33d9fcc3 at 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




More information about the Python-list mailing list