[BioPython] how to set proxy for Bio.WWW

Andrew Dalke dalke at dalkescientific.com
Tue Nov 4 01:38:32 EST 2003


Eckhard Lehmann:
> I want to fetch protein entries from Swissprot, but therefore I need 
> to tell
> BioPython my proxy server + proxy username and password.
>
> Has anyone an idea how to do this?

Bio.WWW uses the urllib module to fetch the entries.

There's no provision to pass in a set of proxies (though that would
be realtively easy to add).  Instead, you'll need to change the default
way it handles proxies, which is different for different OSes.  See
   http://www.python.org/doc/current/lib/module-urllib.html

For unix, set the environment variable 'http_proxy' to the
proxy, as http://username:password@hostname/ ... I think.

However, looking at the code I can't tell if it actually supports
proxies which require an authenticated user name.  It doesn't seem
to, and the search of the back usenet posts suggests that it does
not.  It does seem that urllib2 supports proxies with passwords.

I think you're going to have to experiment a bit.  If setting the
system proxy (eg, through an env variable) doesn't work then
try having Bio.WWW.ExPASy first 'import urllib2' and replace the
urllib.urlopen with urllib2.urlopen

					Andrew
					dalke at dalkescientific.com



More information about the BioPython mailing list