某网站cookies携带https_ydclearance获取正文

1、url

bash 复制代码
aHR0cHM6Ly9iYnMuNTFjcmVkaXQuY29tL3RocmVhZC03ODI0OTAzLTEtMS5odG1s

2、抓包

根据抓包返回的两个请求进行访问,发现获取正文需cookies携带https_ydclearance

bash 复制代码
cookies = {
    'https_ydclearance': '6973fc7d30e4fe01c1bdde9f-ff5e-4d22-bfc2-00e5ab7769b7-1698036076',
}

3、根据返回的第一个请求(521),代码请求url,返回内容如下:

bash 复制代码
<html>
	<body>
		<script language="javascript">
			window.onload = setTimeout("gu(62)", 200);
			function gu(VJ) {
				var qo, mo = "",
				no = "",
				oo = [0x70, 0x5a, 0x61, 0x4e, 0x7b, 0xa7, 0x26, 0x51, 0xdd, 0x2b, 0xbf, 0xac, 0x43, 0xaf, 0x1c, 0x08, 0xb3, 0xe0, 0xb3, 0xe9, 0x5d, 0x29, 0x78, 0xc5, 0x57, 0x26, 0x13, 0x7d, 0x2b, 0x78, 0xf0, 0xdb, 0x28, 0x53, 0xff, 0x0d, 0x7e, 0x29, 0xb5, 0xa2, 0xcd, 0x04, 0x9a, 0xc5, 0xdc, 0x12, 0x1d, 0xd3, 0x5c, 0xa7, 0x33, 0x2a, 0x75, 0x01, 0xa9, 0xa0, 0xb5, 0x4b, 0x38, 0x63, 0xac, 0xb7, 0xce, 0x83, 0x7a, 0xa5, 0xe6, 0xf1, 0xfe, 0xb4, 0x5f, 0x93, 0xd6, 0x4c, 0xa1, 0x77, 0xc4, 0xf8, 0x96, 0xeb, 0x77, 0x8e, 0xa3, 0xd7, 0xdc, 0xe7, 0xfe, 0xd3, 0xc0, 0xf4, 0xb9, 0xe6, 0x9c, 0xb1, 0x67, 0x74, 0x99, 0xf0, 0xc5, 0x9b, 0x48, 0x93, 0x37, 0x24, 0xfa, 0x2d, 0xe3, 0x79, 0xef, 0xa5, 0x7b, 0x52, 0xa7, 0x1d, 0x09, 0xdf, 0xb5, 0xcc, 0xc2, 0x95, 0x8f, 0xbc, 0x8a, 0x57, 0x03, 0x12, 0xd2, 0xfd, 0xec, 0x21, 0x49, 0xb5, 0x49, 0xd5, 0x2a, 0xfe, 0x14, 0x09, 0x8a, 0xbe, 0x25, 0x12, 0x5f, 0x93, 0xe2, 0xf7, 0xee, 0xc1, 0x98, 0x0e, 0x17, 0x2d, 0x84, 0xd9, 0xef, 0x45, 0x42, 0x57, 0x2c, 0x93, 0xbb, 0x05, 0xa7, 0x9d, 0x72, 0xbd, 0x2a, 0x56, 0xab, 0x58, 0x04, 0x90, 0xc6, 0x59, 0x52, 0x87, 0x3e, 0x29, 0x38, 0x63, 0xc4, 0x10, 0xbb, 0x09, 0x9d, 0x8a, 0x73, 0xdf, 0x0c, 0x02, 0xd6, 0xa3, 0xd7, 0x84, 0xd1, 0x9d, 0xd3, 0x48, 0xe7, 0xdd, 0xb2, 0x9b, 0xc8, 0xb3, 0x49, 0x78, 0x85, 0xb2, 0x26, 0x1c, 0x6b, 0xda, 0x86, 0x11, 0x5e, 0xca, 0x8f, 0xfe, 0x91, 0xde, 0x49, 0x36, 0xcb, 0xfa, 0x25, 0x52, 0xde, 0x2c, 0xeb, 0x80, 0xcc, 0x37, 0x24, 0xd0, 0x76, 0xc3, 0x6f, 0xdb, 0x68, 0x9e, 0xcc, 0x40, 0xb4, 0x02, 0xcd, 0xdc, 0x6d, 0x9a, 0x45, 0x92, 0xc6, 0x3c, 0xa6, 0x7c, 0x91, 0xe8, 0x9e, 0x73, 0x96, 0x8b, 0xbf, 0x76, 0xaa, 0x5f, 0x30, 0xc4, 0x90, 0xdd, 0x0a, 0x56, 0xfc, 0xc4, 0x3b];
				qo = "qo=271; do{oo[qo]=(-oo[qo])&0xff; oo[qo]=(((oo[qo]>>1)|((oo[qo]<<7)&0xff))-5)&0xff;} while(--qo>=2);";
				eval(qo);
				qo = 270;
				do {
					oo[qo] = (oo[qo] - oo[qo - 1]) & 0xff;
				} while (-- qo >= 3 );
				qo = 1;
				for (;;) {
					if (qo > 270) break;
					oo[qo] = ((((((oo[qo] + 89) & 0xff) + 242) & 0xff) << 4) & 0xff) | (((((oo[qo] + 89) & 0xff) + 242) & 0xff) >> 4);
					qo++;
				}
				po = "";
				for (qo = 1; qo < oo.length - 1; qo++) if (qo % 6) po += String.fromCharCode(oo[qo] ^ VJ);
				eval("qo=eval;qo(po);");
			}
		</script>
	</body>

</html>

运行此段js结果如下,可知从第一次请求的返回中获取cookies

4、在python中运行js,获取cookies

bash 复制代码
# 取出js方法
js_hanShu = re.findall('(function .*?)</script>', response)[0]
print(js_hanShu)

js_hanShu = str(js_hanShu).replace('eval("qo=eval;qo(po);")', 'return po')
js_run = execjs.compile(js_hanShu)                

js_name = re.findall('setTimeout\("(.*?)\(', response)[0]
print('js_name:', js_name)
js_arg = re.findall('setTimeout\("\D+\((\d+)\)",', response)[0]
print('js_arg:', js_arg)

dCookie = js_run.call(js_name, js_arg)
print(dCookie)

ydclearance = re.findall('https_ydclearance=(.*?);', dCookie)[0]

cookies = {
    'https_ydclearance': ydclearance,
}

5、带cookies再次请求即可获得正文

相关推荐
Amo Xiang1 个月前
2024最新版JavaScript逆向爬虫教程-------基础篇之Chrome开发者工具学习
javascript·chrome·爬虫·js逆向
Amo Xiang1 个月前
2024最新版JavaScript逆向爬虫教程-------基础篇之Proxy与Reflect详解
开发语言·javascript·爬虫·js逆向
Learner_HJ2 个月前
猿人学— 第一届第1题(解题思路附源码)
python·网络爬虫·js逆向·猿人学
坚持不懈的大白4 个月前
Python爬虫:通过js逆向获取某瓜视频的下载链接
javascript·爬虫·js逆向
Regent Wan4 个月前
【js逆向专题】2.浏览器调试技巧
javascript·js逆向
我把把C5 个月前
python爬虫获取网易云音乐评论歌词以及歌曲地址
javascript·数据库·爬虫·python·安全·js逆向·加密
小木_.5 个月前
【快速逆向二/无过程/有源码】掌上高考—2024高考志愿填报服务平台
js逆向·分享
田小涛8 个月前
某翻译平台翻译接口逆向之webpack学习
webpack·js逆向·逆向·js
阿尔法羊8 个月前
自学Python爬虫js逆向(二)chrome浏览器开发者工具的使用
javascript·chrome·爬虫·js逆向
lll...lll8 个月前
携程旅行 abtest
js逆向·酒店·abtest·vm2·携程旅行