If I open a file using urllib2, like so:
remotefile = urllib2.urlopen(\'http://example.com/somefile.zip\')
Is there an easy way to get the
Do you mean urllib2.urlopen? There is no function called openfile in the urllib2 module.
urllib2.urlopen
openfile
urllib2
Anyway, use the urllib2.urlparse functions:
urllib2.urlparse
>>> from urllib2 import urlparse >>> print urlparse.urlsplit('http://example.com/somefile.zip') ('http', 'example.com', '/somefile.zip', '', '')
Voila.