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 6126951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:26:33+00:00 2026-05-23T16:26:33+00:00

I figured out how to use a proxy with urllib2: encoded_params = urllib.urlencode(params) url

  • 0

I figured out how to use a proxy with urllib2:

encoded_params = urllib.urlencode(params)
url = "http://someurl.com"

header = {"User-Agent" : "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"}
proxy = urllib2.ProxyHandler({'http': '193.33.125.217:8080'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)

request = urllib2.Request(url, headers=header)
response = urllib2.urlopen(request)

I hope the code is correct. Perhaps there is a more elegant way? At least it seems to work so far. Is there something like a log or a dictionary with information about the request I made with urllib2? Something that could give me information about the proxy I used, the parameters, the IP I had while querying, perhaps the port and other metadata?

  • 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-23T16:26:34+00:00Added an answer on May 23, 2026 at 4:26 pm

    You are doing everything correctly as far as I can tell. One way to test would be to run a simple web server and connect to it from your proxy. Making a simple test web server is easy:

    from wsgiref.simple_server import demo_app
    from wsgiref.simple_server import make_server
    
    httpd = make_server('0.0.0.0', 8000, demo_app)
    print "Serving on port 8000..."
    httpd.serve_forever()
    

    Assuming you can connect to the web server externally from wherever you run it (not blocked by firewall, etc) you should be able to verify that the proxy address is echoed when it connects. If you do print response.read() you can look at various WSGI environ details. This is fine for testing, but don’t leave the server running forever 🙂

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

Sidebar

Related Questions

I've figured out how to use QPainter to draw rectangles. Now I want to
I have to pass a meta-information in my HTTP response so I figured out
I'm trying to figure out how to robustly handle proxy authentication errors (HTTP 407
I am using this AJAX proxy for cross-domain AJAX requests: http://www.daniweb.com/code/snippet494.html . It works
I am trying to figure out how to use proxy classes in Django. I
I recently figured out how to use ObjectOutputStream and ObjectInputStream to send objects over
I just figured out how to use Facebox. I can open hidden divs in
I've figured out how to use metadata to define the displaynames for table data
I am new to powershell and have figured out how to use it to
I can't figure out the use for this code . Of what use is

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.