Python / Basics / HTTP Request
Http request
-
Step:
1. Get request
import requests x=requests.get('https://w3schools.com/python/demopage.htm') print(x.text) 2. POST Request
url = 'https://www.w3schools.com/python/demopage.php' myobj = {'somekey': 'somevalue'} x = requests.post(url, json = myobj) print(x.text) 3. POST with Header
import requests import json url = "https://httpbin.org/post" headers = {"Content-Type": "application/json; charset=utf-8"} data = { "id": 1001, "name": "geek", "passion": "coding", } response = requests.post(url, headers=headers, json=data) print("Status Code", response.status_code) print("JSON Response ", response.json())