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:28]
billdozor [Using Requests]
python_wiki:requests [2018/08/09 23:37]
billdozor [POST]
Line 109: 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>
 +#!/usr/bin/python
 +
 +import requests
 +
 +# Post the request (this will delay/sleep for 5 seconds)
 +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>
  
 ---- ----
  
  • python_wiki/requests.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)