Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
python_wiki:requests [2018/08/09 23:34] billdozor [POST] |
python_wiki:requests [2018/08/09 23:37] billdozor [POST] |
||
---|---|---|---|
Line 110: | Line 110: | ||
Send data in a POST request. | Send data in a POST request. | ||
+ | \\ | ||
Example: Use the httpbin.org site to delay 5 seconds (will replace with a more interesting example later) | Example: Use the httpbin.org site to delay 5 seconds (will replace with a more interesting example later) | ||
<code bash> | <code bash> | ||
Line 116: | Line 117: | ||
import requests | import requests | ||
+ | # Post the request (this will delay/sleep for 5 seconds) | ||
response = requests.post(" | response = requests.post(" | ||
+ | |||
+ | # Extract the JSON object from the response | ||
+ | data = response.json() | ||
+ | |||
+ | # Show http status code | ||
+ | print(" | ||
+ | |||
+ | print(" | ||
+ | print(data) | ||
</ | </ | ||
---- | ---- | ||