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:22] billdozor [Using Requests] |
python_wiki:requests [2018/08/09 23:37] billdozor [POST] |
||
---|---|---|---|
Line 51: | Line 51: | ||
response = requests.delete(my_site + " | response = requests.delete(my_site + " | ||
+ | ##-- head and options responses are not implemented in the httpbin.org website --## | ||
# HEAD | # HEAD | ||
response = requests.head(my_site) | response = requests.head(my_site) | ||
Line 108: | Line 109: | ||
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) | ||
+ | <code bash> | ||
+ | # | ||
+ | |||
+ | import requests | ||
+ | |||
+ | # Post the request (this will delay/sleep for 5 seconds) | ||
+ | response = requests.post(" | ||
+ | |||
+ | # Extract the JSON object from the response | ||
+ | data = response.json() | ||
+ | |||
+ | # Show http status code | ||
+ | print(" | ||
+ | |||
+ | print(" | ||
+ | print(data) | ||
+ | </ | ||
---- | ---- | ||