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

  • SEARCH
  • Home
  • 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 1081143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:07:44+00:00 2026-05-16T22:07:44+00:00

In windows XP, python 2.5 and 2.6 I tested the following code: import urllib2

  • 0

In windows XP, python 2.5 and 2.6 I tested the following code:

import urllib2
proxy= urllib2.ProxyHandler({'http': '127.0.0.1:8080'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
urllib2.urlopen('http://www.google.com/')

In the above code I get a BadStatusLine exception from line 349 of httplib.py.

I have a proxy running at 127.0.0.1:8080 which works (I can set a browser to use it with proxyswitchy, and when it’s on I can get to sites which are blocked when it’s off [in China]).

if I change it to a socks proxy,

proxy= urllib2.ProxyHandler({'socks': '127.0.0.1:8080'})

Then the proxy is not used at all.

I got the code from the question at Proxy with urllib2 and it’s almost exactly the same – what could be going wrong?

Update: urllib2 doesn’t support socks proxies.

Eventually got it working with curl:

c = pycurl.Curl()

#stupid GFW
if settings.CHINA:
    c.setopt(pycurl.PROXY, '127.0.0.1')
    c.setopt(pycurl.PROXYPORT, 8087)
    c.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5)
  • 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. Editorial Team
    Editorial Team
    2026-05-16T22:07:44+00:00Added an answer on May 16, 2026 at 10:07 pm

    The urllib2 ProxyHandler is not designed to support the SOCKS protocol. Perhaps this answer would help.

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

Sidebar

Related Questions

When using urllib2 (and maybe urllib) on windows python seems to magically pick up
Is there any alternative for WPF (windows presentation foundation) in python? http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF
Python for Windows by default comes with IDLE, which is the barest-bones IDE I've
Hey I have a windows server running python CGI scripts and I'm having a
How to wait for multiple child processes in Python on Windows, without active wait
How do I read text from the (windows) clipboard with python?
Is it possible to write to the windows logs in python?
I installed Python 2.6 for one user on Windows Vista. Python works okay, but
I am running a windows machine have installed Python 2.5. I also used the
In Python, how do I jump to a file in the Windows Explorer? I

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.