1>>> import requests
2>>> r = requests.post('http://httpbin.org/post', json={"key": "value"})
3>>> r.status_code
4200
5>>> r.json()
6{'args': {},
7 'data': '{"key": "value"}',
8 'files': {},
9 'form': {},
10 'headers': {'Accept': '*/*',
11 'Accept-Encoding': 'gzip, deflate',
12 'Connection': 'close',
13 'Content-Length': '16',
14 'Content-Type': 'application/json',
15 'Host': 'httpbin.org',
16 'User-Agent': 'python-requests/2.4.3 CPython/3.4.0',
17 'X-Request-Id': 'xx-xx-xx'},
18 'json': {'key': 'value'},
19 'origin': 'x.x.x.x',
20 'url': 'http://httpbin.org/post'}
1# pip install requests
2import requests
3req = requests.get('<url here>', 'html.parser')
4print(req.text)
1import socket
2
3target_host = "www.google.com"
4target_port = 80
5
6# create a socket object
7client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
8
9# connect the client
10client.connect((target_host,target_port))
11
12# receive some data
13response = client.recv(4096)
14print(f'Source Code: {response}')
15http_response = repr(response)