Using internet modules to download files
Gerhard Häring
gerhard.haering at gmx.de
Tue Sep 24 16:05:15 EDT 2002
Stuart wrote in comp.lang.python:
> I have a slight problem. The college which I attend has broadband
> access for everyone, but unfortunately insists upon placing a firewall
> between the pupils and downloads, therefore this fast connection is
> wasted upon retrieving HTML files.
So the "firewall" restricts you to downloading HTML documents only?
Are you not able to view any images in a browser? Can you not download
any .exe, .zip, .tgz files?
> I merely want to use the broadband to download a few more python
> libraries, such as win32all, as my home pc doesn't have internet
> access.
>
> I have been experimenting with Python's internet protocols, in
> particular with trying to retreive files while bypassing the firewall.
> I am not sure, however, which modules to use (i am a relative python
> neophyte). I first tried with urllib, but that unforunately merely
> routes you throught the webbrowser, which of course, promptly blocks
> any attempt.
No, urllib doesn't use any webbrowser. It may be that you'll have to
instruct it to use a proxy server (and it sounds like your "firewall"
has one). Did you try urllib.urlretrieve, yet?
Using it like this:
urllib.urlretrieve("http://python.org/", "pydotorg.html") will
download the http://python.org entry page as the file pydotorg.html.
At least here ;-)
> Are then any modules which will bypass the
> browser/firewall, and allow you to download a file directly through
> the script? Any advice (especially samples of code) would be greatly
> appreciated.
See the above one-liner.
-- Gerhard
More information about the Python-list
mailing list