script that able to download zip file from server
<p>Can you please help me to make script in python that do the following:</p>

<ol>
<li>download zip file http (I already have a code for this one)</li>
<li>download zip file in <code>file://&lt;server location&gt;</code>, I have problem with this one. the location of the file is in <code>file://&lt;server location&gt;file.zip</code></li>
</ol>

<p>can't download the #2 file :(</p>

<p>Code below, #1 is working if using HTTP, but when using <code>file:////</code> it's not working. Anybody has idea how to download a zip file from <code>file:////</code>?</p>

<pre><code>import urllib2
response = urllib2.urlopen('file:////server/file.zip')
print response.info()
html = response.read()
# do something
response.close()  # best practice to close the file
</code></pre>

<p>urllib2 does not have handlers for the <code>file://</code> protocol; I think it will open local files if there is <em>no</em> protocol given (<code>//server/file.zip</code>), but I've never used that, and haven't tested it.  If you have a local file name, you can just use <code>open()</code> and <code>read()</code> rather than urrlib2.</p>

<p>Your code will be simpler if you use <code>with closing</code> (from <code>contextlib</code>); opened files are already context managers in Python 2.7 and 3.x, so they're even easier to use.</p>

python urllib2