string cookie = instance.GetCookie(); // берет все куки
//string cookie = instance.GetCookie("yandex.ru", false); // берет конкретно с сайта
Func<string, long> time = delegate(string times){
string format = @"M/d/yyyy HH:mm:ss"; // 12/26/2021 12:00:19
TimeSpan ts = new TimeSpan();
DateTime baseDt = new DateTime(1970, 1, 1);
try{
DateTime d = DateTime.ParseExact(times, format, System.Globalization.CultureInfo.InvariantCulture);
ts = d - baseDt;
}
catch (FormatException) {
ts = baseDt - baseDt;
}
// return (long)ts.TotalSeconds; // "expirationDate":1640536129
return (long)ts.TotalMilliseconds; // "expirationDate":1640518129000
};
string[][] splited = cookie.Split(new []{"\r\n"}, StringSplitOptions.None)
.Select(s => s.Split('\t')).Where(w => w.Length >= 6)
.ToArray();
List<object> result = new List<object>();
foreach (var par in splited){
result.Add(new {
domain = par[0],
expirationDate = time(par[4].Trim()),
httpOnly = par[1] == "TRUE",
name = par[5],
path = par[2],
secure = par[3] == "TRUE",
value = par[6]
});
}
return Global.ZennoLab.Json.JsonConvert.SerializeObject(result);