|
|
|
@ -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)
|
|
|
|
|