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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:34:56+00:00 2026-05-12T22:34:56+00:00

Does urllib2 fetch the whole page when a urlopen call is made? I’d like

  • 0

Does urllib2 fetch the whole page when a urlopen call is made?

I’d like to just read the HTTP response header without getting the page. It looks like urllib2 opens the HTTP connection and then subsequently gets the actual HTML page… or does it just start buffering the page with the urlopen call?

import urllib2
myurl = 'http://www.kidsidebyside.org/2009/05/come-and-draw-the-circle-of-unity-with-us/'
page = urllib2.urlopen(myurl) // open connection, get headers

html = page.readlines()  // stream page
  • 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-12T22:34:57+00:00Added an answer on May 12, 2026 at 10:34 pm

    Use the response.info() method to get the headers.

    From the urllib2 docs:

    urllib2.urlopen(url[, data][, timeout])

    …

    This function returns a file-like object with two additional methods:

    • geturl() — return the URL of the resource retrieved, commonly used to determine if a redirect was followed
    • info() — return the meta-information of the page, such as headers, in the form of an httplib.HTTPMessage instance (see Quick Reference to HTTP Headers)

    So, for your example, try stepping through the result of response.info().headers for what you’re looking for.

    Note the major caveat to using httplib.HTTPMessage is documented in python issue 4773.

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

Sidebar

Related Questions

I was condering when I use urllib2.urlopen() does it just to header reads or
I have a python file like this import urllib2 try: data = urllib2.urlopen('http:....').read() except
urllib2.urlopen(theurl).read() ...this downloads the file. urllib2.urlopen(theurl).geturl() ...does this download the file? (how long does
I have a Python script that loads a web page using urllib2.urlopen , does
The function urllib2.urlopen freezes. So my question is simple: Why does urlopen freeze my
When I try to post data from http to https, urllib2 does not return
my code: proxy = urllib2.ProxyHandler({'http': '127.0.0.1:8888'}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) f = urllib2.urlopen('http://www.google.com') print
I'm using data=urllib2.urlopen(url).read() I want to know: How can I tell if the data
I have following python code: def scrapeSite(urlToCheck): html = urllib2.urlopen(urlToCheck).read() from BeautifulSoup import BeautifulSoup
I'm curious, how come I get 404 error running this line: urllib2.urlopen(http://localhost/new-post#comment-29) While everything

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.