Differences
This shows you the differences between two versions of the page.
python_wiki:requests [2018/08/05 15:09] billdozor [Using Requests] |
python_wiki:requests [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Requests ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | The requests library is a http library that allows you to interact with web servers via Python. | ||
- | |||
- | **Checklist** | ||
- | * Python 2 or 3 | ||
- | |||
- | ---- | ||
- | |||
- | ====== Install ====== | ||
- | |||
- | Requests can be installed via pip | ||
- | <code bash> | ||
- | pip install requests | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ====== Import ====== | ||
- | |||
- | <code python> | ||
- | import requests | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ====== Using Requests ====== | ||
- | |||
- | Requests supports the following http request types. | ||
- | <code python> | ||
- | my_site = " | ||
- | |||
- | # GET | ||
- | response = request.get(my_site) | ||
- | |||
- | # POST | ||
- | response = request.post(my_site) | ||
- | |||
- | # PUT | ||
- | response = request.put(my_site) | ||
- | |||
- | # DELETE | ||
- | response = request.delete(my_site) | ||
- | |||
- | # HEAD | ||
- | response = request.head(my_site) | ||
- | |||
- | # OPTIONS | ||
- | response = request.options(my_site) | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== GET ===== | ||
- | |||
- | Using the GET request and handling the response data. | ||
- | |||
- | ---- | ||
- | |||
- | ===== POST ===== | ||
- | |||
- | Send data in a POST request. | ||
- | |||
- | ---- | ||