Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
python_wiki:requests [2018/08/09 23:22] billdozor [Using Requests] |
python_wiki:requests [2019/05/25 23:50] (current) |
||
---|---|---|---|
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 89: | Line 90: | ||
print(" | print(" | ||
print(" | print(" | ||
+ | print(" | ||
</ | </ | ||
Line 98: | Line 100: | ||
-- The Current XKCD Comic -- | -- The Current XKCD Comic -- | ||
- | Comic Title: | + | Comic Title: |
- | Comic Text: I'm trying | + | Comic Text: If you can't get your graphing tool to do the shading, just add some clip art of cosmologists discussing |
- | Comic Date: 2018-8-3 | + | Comic Date: 2018-8-10 |
+ | Comic Image URL: https:// | ||
</ | </ | ||
Line 108: | Line 111: | ||
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) | ||
+ | </ | ||
---- | ---- | ||