python登录微博(非无头浏览器)
深夜发个帖子python登录微博,非无头浏览器
在截图上面更改自己的账号密码即可,登录验证码会在运行根目录生成png文件,查看后输入即可
post提交数据后,返回登陆地址,无痕浏览器输入后,刷新重新进入weibo.com即可登录,post构造数据使用js解密。
本贴主要是用来学习交流
github地址:https://github.com/hkslover/weibo
chensure 发表于 2020-3-4 12:52
已经抓包,不会逆向
首页
wxcs.#####gdzyz.####cn
import requests
import hashlib
def login_session(user,password):
m = hashlib.md5()
pwd_txt = password.encode(encoding='utf-8')
m.update(pwd_txt)
pwd_md5 = m.hexdigest()
session = requests.session()
url = 'https://wxcs.gdzyz.cn/loginWx/personalLogin?loginType=2'
response = session.get(url)
print(response.cookies)
data = {
'backUrl': '/common/weixinInvoke/isWeixinInvoke.do?type=0',
'loginType': '2',
'userName': user,
'idcardType': '255',
'password': pwd_md5,
}
url = 'https://wxcs.gdzyz.cn/loginWx/userWzLogin.do'
headers = {
'Host': 'wxcs.gdzyz.cn',
'Origin': 'https://wxcs.gdzyz.cn',
'Referer': 'https://wxcs.gdzyz.cn/loginWx/personalLogin?loginType=2',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36'}
response = session.post(url,headers = headers,data = data)
print(response.text)
if __name__ == "__main__":
login_session('snowsnow','123456')
我这里输入的账号密码是错误的,所以 提示
用python写登录请求我觉得尽量使用session,不要给自己添麻烦,session自动处理cookie
hksnow 发表于 2020-3-4 11:35
网站给我我研究研究
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value.
*
* @Param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cAt Plugins/Cookie
* @AuThor Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @Return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = .join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
}; 我想知道这种浏览器有什么用处 如果要输验证码咋办? GleeChan 发表于 2020-3-4 00:20
如果要输验证码咋办?
楼主说了的嘛,目录底下有个验证码的图片文件,查看后输入 这样子,是不是也能获取cookie? chensure 发表于 2020-3-4 00:36
这样子,是不是也能获取cookie?
肯定可以啊 hksnow 发表于 2020-3-4 06:52
肯定可以啊
我要登录的网站是这样子的,
打开网址,得到一个JSESSIONID,
调用js形成第一个cookie(本地)
第一个cookie+账户密码 形成第二个cookie
post登录带 账户、密码、第二个cookie
第二个cookie 正式生效
其中调用js这块,怎么生成? chensure 发表于 2020-3-4 09:40
我要登录的网站是这样子的,
打开网址,得到一个JSESSIONID,
调用js形成第一个cookie(本地)
抓包逆向js啊 chensure 发表于 2020-3-4 09:40
我要登录的网站是这样子的,
打开网址,得到一个JSESSIONID,
调用js形成第一个cookie(本地)
网站给我我研究研究 本帖最后由 chensure 于 2020-3-4 12:54 编辑
hksnow 发表于 2020-3-4 11:35
网站给我我研究研究
已经抓包,不会逆向
首页
wxcs.#####gdzyz.####cn
登录页面
https://wxcs.#####gdzyz.####cn/loginWx/personalLogin?loginType=2
用户页面
https://wxcs.#####gdzyz.####cn/loginWx/userInfo.do
请恕我无法提供账户密码,涉及太多人的个人资料
页:
[1]
2