30
loading...
This website collects cookies to deliver better user experience
import urllib3
http = urllib3.PoolManager()
resp = http.request("GET", "http://httpbin.org/robots.txt")
resp.status
200
resp.data
b'User-agent: *\nDisallow: /deny\n'
import requests
resp = requests.get("http://httpbin.org/robots.txt")
resp.status_code
200
res.text
'User-agent: *\nDisallow: /deny\n'
import urllib3
http = urllib3.PoolManager()
resp = http.request(
"POST",
"https://httpbin.org/post",
fields={"hello": "world"}
)
print(resp.data)
import requests
resp = requests.post(
"https://httpbin.org/post",
data={"hello": "world"}
)
print(res.text)
import json
import urllib3
data = {"attribute": "value"}
# Encoding the data in JSON format.
encoded_data = json.dumps(data).encode("utf-8")
http = urllib3.PoolManager()
resp = http.request(
"POST",
"https://httpbin.org/post",
body=encoded_data, # Embedding JSON data into request body.
headers={"Content-Type": "application/json"}
)
json.loads(resp.data.decode("utf-8"))
import requests
resp = requests.post('https://httpbin.org/post',
json={"attribute": "value"}
)
resp.json()