|
|
|
@ -105,12 +105,12 @@ if __name__ == '__main__':
|
|
|
|
|
# 换算出过期时间
|
|
|
|
|
expiry_time = time.localtime(expiry)
|
|
|
|
|
expiry_date = time.strftime("%Y-%m-%d %H:%M:%S", expiry_time)
|
|
|
|
|
print("cookies的过期时间一般是4天,cookies过期时间:", expiry_date)
|
|
|
|
|
logger.info("cookies的过期时间一般是4天,cookies过期时间:", expiry_date)
|
|
|
|
|
# 获取当前时间戳
|
|
|
|
|
current_timestamp = time.time()
|
|
|
|
|
# 检查是否已过期
|
|
|
|
|
if current_timestamp > expiry:
|
|
|
|
|
print("Cookie已过期")
|
|
|
|
|
logger.error("Cookie已过期")
|
|
|
|
|
exit()
|
|
|
|
|
# 移除expiry属性
|
|
|
|
|
del cookies["expiry"]
|
|
|
|
@ -136,12 +136,11 @@ if __name__ == '__main__':
|
|
|
|
|
response = requests.get(url=url, allow_redirects=False, cookies=cookies)
|
|
|
|
|
if 'Location' in response.headers:
|
|
|
|
|
redirect_url = response.headers.get("Location")
|
|
|
|
|
print("重定向URL:", redirect_url)
|
|
|
|
|
logger.info("重定向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)
|
|
|
|
|
logger.info("获取到的token:", token)
|
|
|
|
|
|
|
|
|
|
article_urls = []
|
|
|
|
|
|
|
|
|
@ -207,7 +206,7 @@ if __name__ == '__main__':
|
|
|
|
|
if '试卷' in article_title: # 过滤掉试卷
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
print(f"正在处理文章: {article_title} ({publish_time})")
|
|
|
|
|
logger.info(f"正在处理文章: {article_title} ({publish_time})")
|
|
|
|
|
content = get_article_content(article_url)
|
|
|
|
|
|
|
|
|
|
loop = asyncio.new_event_loop()
|
|
|
|
|