def read_cookie(self):
cookiesfilepath="cookies%s" % self.uid
if os.path.exists(cookiesfilepath):
ctime = os.path.getctime(cookiesfilepath)#获取文件创建时间
create = datetime.datetime.fromtimestamp(ctime) + datetime.timedelta(days=+1) #当前天加1
nowdate = datetime.datetime.now()
if(nowdate>create):
os.remove(cookiesfilepath)
return False
else:
try:
with open("cookies%s" % self.uid, "rb") as fs:
data = pickle.load(fs)
return data
except:
get_logger().info("Cookies Not In Disk")
return False
# 初始化url
转载于:https://www.cnblogs.com/c-x-a/p/8477496.html
相关资源:JAVA上百实例源码以及开源项目