python http认证

Requests 库有一个auth 模块专门用来处理HTTP 认证:


import requests
from requests.auth import AuthBase
from requests.auth import HTTPBasicAuth


auth = HTTPBasicAuth('ryan', 'password')
r = requests.post(url="http://pythonscraping.com/pages/auth/login.php", auth=auth)
print(r.text)

posted @ 2018-10-26 21:50  寒江小筑  阅读(759)  评论(0编辑  收藏  举报