python_wiki:requests

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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("http://httpbin.org/delay/5") response = requests.post("http://httpbin.org/delay/5")
 +
 +# Extract the JSON object from the response
 +data = response.json()
 + 
 +# Show http status code
 +print("Status code is:" + str(response.status_code))
 +
 +print("Returned response is:")
 +print(data)
 </code> </code>
  
 ---- ----
  
  • python_wiki/requests.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)