Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 70551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:44:55+00:00 2026-05-10T19:44:55+00:00

When using urllib2 (and maybe urllib) on windows python seems to magically pick up

  • 0

When using urllib2 (and maybe urllib) on windows python seems to magically pick up the authenticated proxy setting applied to InternetExplorer. However, it doesn’t seem to check and process the Advance setting ‘Exceptions’ list.

Is there a way I can get it to process the exceptions list? Or, ignore the IE proxy setting and apply my own proxy opener to address this issue?

I played with creating a proxy opener before, but couldn’t get it to work. Here’s what I managed to dig out, but I still don’t see how/where to apply any exceptions and I’m not even sure if this is right:

proxy_info = {                       'host':'myproxy.com',                       'user':Username,                       'pass':Password,                       'port':1080                       }                                                     http_str = 'http://%(user)s:%(pass)s@%(host)s:%(port)d' % proxy_info  authInfo = urllib2.HTTPBasicAuthHandler() authInfo.add_password() proxy_dict = {'http':http_str} proxyHandler = urllib2.ProxyHandler(proxy_dict)  # apply the handler to an opener proxy_opener = urllib2.build_opener(proxyHandler, urllib2.HTTPHandler)  urllib2.install_opener(proxy_opener) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:44:56+00:00Added an answer on May 10, 2026 at 7:44 pm

    By default urllib2 gets the proxy settings from the environment variable, which is why it is using the IE settings. This is very handy, because you don’t need to setup authentication yourself.

    You can’t apply exceptions like you want to, the easiest way to do this would be to have two openers and decide which one to use depending on whether the domain is in your exception list or not.

    Use the default opener for when you want to use the proxy, and one without a proxy for when you don’t need it:

    >>> no_proxy = urllib2.ProxyHandler({}) >>> opener = urllib2.build_opener(no_proxy) >>> urllib2.install_opener(opener) 

    From here.

    Edit:

    Here’s how I’d do it:

    exclusion_list = ['http://www.google.com/', 'http://localhost/']  no_proxy = urllib2.ProxyHandler({}) no_proxy_opener = urllib2.build_opener(no_proxy)  default_proxy_opener = urllib2.build_opener()  url = 'http://www.example.com/'  if url in exclusion_list:     opener = no_proxy_opener else:     opener = default_proxy_opener  page = opener.open(url) print page 

    Your biggest problem will be matching the url to the exclusion list, but that’s a whole new question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 170k
  • Answers 170k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer wrong glMatrixMode? May 12, 2026 at 2:03 pm
  • Editorial Team
    Editorial Team added an answer The best thing I can suggest is a query for… May 12, 2026 at 2:03 pm
  • Editorial Team
    Editorial Team added an answer As it's a Java app, not a document as such,… May 12, 2026 at 2:03 pm

Related Questions

I am creating a C++ Win32 dll with some global data. There is a
I am using urllib2 to post data to a form. The problem is that
I need to download several files via http in Python. The most obvious way
I'm trying to add authenticating proxy support to an existing script, as it is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.