9

I want to access websites without using their API. Would i do this by using something like Mechanize?

4 Answers 4

9

Two suggested answers:

http://docs.python.org/library/httplib.html

http://docs.python.org/library/urllib.html

Good introduction is also a chapter from Dive into Python3 Chapter 13. HTTP Web Services

Sign up to request clarification or add additional context in comments.

3 Comments

Ofcourse i've used Google, but i thought there were frameworks that would do all of the mundane tasks by itself. Thanks anyway.
Why I hate the anwer "ask google": the answers I find on SO after asking google always want me to ask google.
@dwich, the "Chapter 11..." link in your answer is no longer available.
8

You can access websites by HTTP protocol client: httplib

Though maybe you'd like urllib2, in specific the urllib2.urlopen

Here's little example about using urllib2:

import urllib2
page = urllib2.urlopen("http://example.com/").read()
print page

Comments

4
#for Python 3.2
import urllib.request
page = urllib.request.urlopen("http://www.google.com")
print (page.read())

Comments

3

Use urllib.request in python 3.x, and urllib2 in python 2.x

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.