58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Enums;
|
|
using Api.Framework.SDK;
|
|
using CsharpHttpHelper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TBAppraisalTools
|
|
{
|
|
class RefreshTbCookiesThread : TimerTask
|
|
{
|
|
private HttpHelper http = new HttpHelper();
|
|
|
|
public override void Run(object state, bool timedOut)
|
|
{
|
|
try
|
|
{
|
|
var loginInfos = Class1.Config.TbLoginInfos.Where(f => f.OnLine == SwitchType.开启);
|
|
foreach (var tbInfo in loginInfos)
|
|
{
|
|
try
|
|
{
|
|
var item = http.GetItem("https://shoucang.taobao.com/shop_collect_list.htm", tbInfo.Cookies);
|
|
var result = http.GetHtml(item);
|
|
var html = result.Html.Trim();
|
|
if (html.Contains("\"登录页面\"改进建议"))
|
|
{
|
|
tbInfo.OnLine = SwitchType.关闭;
|
|
EventClient.OnEvent(this, $"评价工具 - {tbInfo.TbLoginName} 的心跳包已经过期");
|
|
}
|
|
else
|
|
{
|
|
tbInfo.Cookies = result.UpdateCookies(tbInfo.Cookies);
|
|
tbInfo.OnLine = SwitchType.开启;
|
|
EventClient.OnEvent(this, $"评价工具 - {tbInfo.TbLoginName} 的心跳成功");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
EventClient.OnEvent(this, $"评价工具 - 淘宝心跳异常:{ex.Message}");
|
|
}
|
|
finally
|
|
{
|
|
//Api.Framework.Tools.Util.Save(Class1.Config);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
EventClient.OnEvent(this, $"评价工具 - 淘宝心跳:{ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|