Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do I set up proxy authentication using Python urllib2?

Posted on 2008-10-09
1
4,843 Views
Last Modified: 2012-06-21
I am trying to access a website on my corporate intranet from a Python program.
The intranet is set up to use a proxy server and the proxy server requires authentication.
>>> try:
...       urllib2.urlopen("http://lmaprda01:8080/etc/etc")
... except IOError, e:
...       print e.headers
...       
Via: 1.1 GIPPRDW02
Proxy-Authenticate: Negotiate
Proxy-Authenticate: Kerberos
Proxy-Authenticate: NTLM
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 4112  

I've read the urllib2 howto on python.org but it shows how to authenticate on the site not on the proxy and the proxy example is too sketchy for me to figure it out.
Part of the problem may be that I don't really know my username. Is it Windows-style domain\username or does the domain live in the realm? And if not how can I find out what the realm is?
0
Comment
Question by:PaulKeating
1 Comment
 
LVL 5

Accepted Solution

by:
PaulKeating earned 0 total points
ID: 22685229
A colleague points out that since the url is on the corporate intranet I should not be going through a proxy. Instead I should knock out the proxy handler, which is described in the howto on python.org
>>> proxy_support = urllib2.ProxyHandler({})
>>> opener = urllib2.build_opener(proxy_support)
>>> urllib2.install_opener(opener)
>>> urllib2.urlopen('http:// etc')
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing Python 2.7.3 version on Windows operating system For installing Python first we need to download Python's latest version from URL" www.python.org " You can also get information on Python scripting language from the above mentioned we…
Common practice undertaken by most system administrators is to document the configurations and final solutions of anything performed by them for their future use and reference. So here I am going to explain how to export ISA Server 2004 Firewall pol…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question