From 351caa4b5bfa863475cbe58956ca32d665a1d478 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Mon, 14 Jul 2025 14:51:43 +0800 Subject: [PATCH] 'commit' --- dsLightRag/Test/TestCrawl.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dsLightRag/Test/TestCrawl.py b/dsLightRag/Test/TestCrawl.py index 8fcde632..ba3d7b66 100644 --- a/dsLightRag/Test/TestCrawl.py +++ b/dsLightRag/Test/TestCrawl.py @@ -62,9 +62,18 @@ if __name__ == '__main__': logging.info("登录公众号失败,获取cookie失败") exit() cookies = json.dumps(post) - print(cookies) - print(driver.current_url) + # 方法3:使用requests库发送请求获取重定向URL + url = 'https://mp.weixin.qq.com' + response = requests.get(url=url, allow_redirects=False, cookies=post) + if 'Location' in response.headers: + redirect_url = response.headers.get("Location") + print("重定向URL:", redirect_url) + token_match = re.findall(r'token=(\d+)', redirect_url) + if token_match: + token = token_match[0] + print("获取到的token:", token) + logging.info("微信token:" + token) #url = 'https://mp.weixin.qq.com' #response = requests.get(url=url, allow_redirects=False, cookies=cookies)