python - how to download file by urllib2.urlopen -
i know how download simple file urrlib2.urlopen
but end url not simple has special character in :
" www.math.ualberta.ca/mss/misc/a mathematician's apology.pdf "
special character mathematician's ' in path
some how know
http://www.math.ualberta.ca/mss/misc/a%20mathematician%27s%20apology.pdf
is url have use download file if don't have kind of end url me every time
please give me solution can download file has special url
i have basic method can used don't know how use
- urllib.quote(string[, safe])
- urllib.quote_plus(string[, safe])
- urllib.unquote(string)
- urllib.unquote_plus(string)
please me method example
thank
why not use this?
filename = url.split('/')[-1] cleanurl = urllib.quote(url) urllib.urlretrieve(cleanurl, filename)
Comments
Post a Comment