A, Requests library
r = requests.gets (url) Constructs a request to the server resource Request object, a Response object contains the server returns the resource
requests.get (url, the params = None, ** kwargs)
url: url of the linked pages intended acquisition
params: additional parameters in the url, dictionary or byte stream format, optional
** kwargs: 12 access control parameters
In fact, requests to provide a total of seven commonly used methods, six behind the method is implemented by calling request () method.
Response includes the returns of the entire contents of reptiles
Second, the property of the Response object
analysis:
Third, abnormal requests library
Fourth, the simple use of the library Requests
The first small reptiles:
>>>import requests
>>>r=requests.get("http://www.baidu.com")
>>>print(r.stauts_code)
200 说明成功
>>>type(r)
<class 'requests.models.Response'>
>>>r.headers
{...}
>>>r.encoding
>>>r.apparent_encoding
>>>r.encoding='utf-8'
r.encoding: If charset header does not exist, encoding is considered as ISO-8859-1 (less accurate)
r.apparent_encoding: The encoding of the analyzed page content (more accurate)