@
wex #!/usr/bin/env python
# -*- coding:UTF-8 -*
import requests
import re
import simplejson as json
session = requests.Session()
url = '
http://account.lvye.cn/accounts/login'response = session.get(url)
content = response.content
pattern = r'<input type=\'hidden\' name=\'csrfmiddlewaretoken\' value=\'([^\s]+?)\' />'
token = re.search(pattern, content).group(1)
data = {
'username': 'ly233',
'password': 'ly233233',
'cap_code': '',
'auto': 'on',
'csrfmiddlewaretoken': token,
'next': '
http://lvye.cn',
'client_id': 'None',
'state': 'None',
'cap_key': '',
'login_code': ''
}
url = '
http://account.lvye.cn/accounts/ajax_login/'response =
session.post(url, data=data)
content = response.content
result = json.loads(content)
print 'uid: %s , username: %s , email: %s' % (result.get('uid'), result.get('name'), result.get('email'))