KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to download several files via http in Python. The most obvious way to do it is just using urllib2: import urllib2 u = urllib2.urlopen('http://server.com/file.html') localFile = open('file.html', 'w') localFile.write(u.read()) localFile.close() But I'll have to deal with the URLs that are nasty in some way, say like this: http://server.com/!Run.aspx/someoddtext/somemore?id=121&m=pdf . When downloaded via the browser, the file has a human-readable name, ie. accounts.pdf . Is there any way to handle that in python, so I don't need to know the file names and hardcode them into my script?
Tags (comma-separated)
Save Edits
Cancel