WebScraping (Day 1)
*** get and post request ***
Preparation: python 3.7 and VS code.
Library Require: requests
- 学习get与post请求,尝试使用requests或者是urllib用get方法向百度一下,你就知道发出一个请求,并将其返回结果输出。
See the below code
The content of response is shown.
Post request
Result print
- 如果是断开了网络,再发出申请,结果又是什么。了解申请返回的状态码。
After disconnection, the result shows
Status code: r.status_code
[Errno 11001]: getaddrinfo failed
[200]: request get
[302]: request post
- 了解什么是请求头,如何添加请求头。
Headers is a parameter, if you want to add HTTP headers to a request.