import requests
import json
login_url = 'http://www.xxxxxx.com/wp-login.php'
def get_cookie(account, password):
s = requests.Session()
payload = {
'log' : account,
'pwd' : password,
'rememberme' : 'forever',
'wp-submit' : "Log In",
'redirect_to' : 'http://www.xxxxxx.com/wp-admin/',
'testcookie' : '1'
}
response = s.post(login_url, data= payload)
cookies = response.cookies.get_dict()
return json.dumps(cookies)
print(get_cookie('xxx', 'xxxxx'))
http://www.codeblogbt.com/archives/126737