How to access the network using Python?

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

+4
source share
4 answers

If you just ask Google , you will get at least two answers.

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

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

A good introduction is also a chapter from Dive in Python. Chapter 11. HTTP Services

+7
source

You can access websites through the HTTP protocol client: httplib

Although perhaps you would like urllib2 , in particular urllib2.urlopen

Here is a small example about using urllib2:

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

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

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

Source: https://habr.com/ru/post/1316455/


All Articles