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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:47:10+00:00 2026-05-27T00:47:10+00:00

I am trying to connect to websites with Python and get the HTTP status

  • 0

I am trying to connect to websites with Python and get the HTTP status codes. As answers on this other question of mine suggest, the reason that HTTP status code for websites such as google.com are 301 or 302 (permanently moved) is that these servers are redirecting. However, I would like to be able to connect to them in such a manner that I get the natural 200 (OK) from them. Here’s my current code:

import httplib

conn = httplib.HTTPConnection("google.com", 80)
conn.request("GET","/")
r  = conn.getresponse()
print r.status, r.reason
conn.close()

What do I need to alter/add to achieve this? I heard that pycurl library might help me with that, but googling hasn’t brought any useful results so far. I am a novice in this field, so please excuse me if the question is trivial.

  • 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-27T00:47:10+00:00Added an answer on May 27, 2026 at 12:47 am

    I assume what you want is for your code to follow the 301/302s to the end url which returns a 200?

    If so you could try using urllib, or better still use requests which you can install with pip.

    Both urllib and more reliably requests should follow 301’s and 302’s and give you the final page that returns a 200.

    Info on the requests module can be found here:
    http://pypi.python.org/pypi/requests/

    Hope this helps.

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

Sidebar

Related Questions

This might be a stupid question but, I am trying to connect to a
I am trying to integrate one of my websites with facebook connect. I have
so I've been trying to make this bot in python that uses sockets to
So I am trying to connect to my company's website through an HTTP authentication
When trying to connect to an ORACLE user via TOAD (Quest Software) or any
While trying to connect to a database that's set to read only, the connection
I am trying to connect to a Microsoft SQL 2005 server which is not
I am trying to connect to 2 databases on the same instance of MySQL
I am trying to connect to simple webparts in my sharepoint team site, i
I am trying to connect to a webservice over ssl with a client certificate.

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.