demo_requests_head_auth.py:
import requests url = 'https://www.begtut.com/python/demopage.php' #use the 'auth' parameter to send requests with HTTP Basic Auth: x = requests.head(url, auth = ('user', 'pass')) print(x.status_code)
➜ begtut>python demo_requests_head_auth.py
200