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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:59:55+00:00 2026-05-17T16:59:55+00:00

hello there i was wondering if it was possible to connect to a http

  • 0

hello there
i was wondering if it was possible to connect to a http host (I.e. for example google.com)
and download the source of the webpage?

Thanks in advance.

  • 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-17T16:59:56+00:00Added an answer on May 17, 2026 at 4:59 pm

    Using urllib2 to download a page.

    Google will block this request as it will try to block all robots. Add user-agent to the request.

    import urllib2
    user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3'
    headers = { 'User-Agent' : user_agent }
    req = urllib2.Request('http://www.google.com', None, headers)
    response = urllib2.urlopen(req)
    page = response.read()
    response.close() # its always safe to close an open connection
    

    You can also use pyCurl

    import sys
    import pycurl
    
    class ContentCallback:
            def __init__(self):
                    self.contents = ''
    
            def content_callback(self, buf):
                    self.contents = self.contents + buf
    
    t = ContentCallback()
    curlObj = pycurl.Curl()
    curlObj.setopt(curlObj.URL, 'http://www.google.com')
    curlObj.setopt(curlObj.WRITEFUNCTION, t.content_callback)
    curlObj.perform()
    curlObj.close()
    print t.contents
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
I was reading the Gallery View tutorial : http://developer.android.com/resources/tutorials/views/hello-gallery.html . Is there anyway I
Possible Duplicate: New Cool Features of C# 4.0 Hello, There are several(many) questions at
Hello I was wondering if it was possible to store a double into a
Hello I am wondering whether it is possible to do this type of regex:
Hello wondering if there is an easier way to display odd / even numbers.
Hello I was wondering if there is a nice way to find out what
hello i am new to phpexcel, and i was wondering if there is some
Hello Python experts, I am wondering if there is any shorter way to assign
Hello i am wondering if there is a way to check if a certain

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.