1# from http://zetcode.com/python/requests/
2import requests as req
3
4resp = req.get("http://www.webcode.me")
5
6print(resp.text)
1import requests
2
3x = requests.get('https://w3schools.com')
4print(x.status_code)
1import requests
2
3response = requests.get('<api-endpoint>')
4response.raise_for_status()
5
6data = response.json()
7print(data)
1import requests
2
3r = requests.get('https://api.github.com', auth=('user', 'pass'))
4
5print r.status_code
6print r.headers['content-type']
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)