demo_requests_post_auth.py:
import requests url = 'https://begtut.com/python/demopage.php' myobj = {'somekey': 'somevalue'} #use the 'auth' parameter to send requests with HTTP Basic Auth: x = requests.post(url, data = myobj, auth = ('user', 'pass')) print(x.status_code)
➜ begtut>python demo_requests_post_auth.py
200