1
wex OP |
2
wex OP 这个咋么编辑?
|
3
wex OP |
4
caspartse 2016-04-23 00:15:04 +08:00
post 的 url 应该是 http://account.lvye.cn/accounts/ajax_login/
|
5
eoo 2016-04-23 02:47:17 +08:00 via Android
PHP 搞起
|
7
ming2281 2016-04-23 10:24:13 +08:00 1
与题目无关的几点
找 login-url 时一定要找对,具体是查看 chrome 控制台的 Request-URL 那里 使用 requests, 从此模拟登陆不要太简单!(幸福感大大提升) 读读其文档,也就一两小时, 神兵利器 |
8
caspartse 2016-04-23 11:03:03 +08:00
@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')) |