Commit def8be30 authored by 黄奎's avatar 黄奎

111

parent fd4f06d2
......@@ -68,7 +68,7 @@ namespace TicketSpider.Spiders.ClassInRule
IWebElement pwdEle;
var option = new ChromeOptions();
option.AddArgument("--incognito");
//option.AddArgument("headless");
option.AddArgument("headless");
option.AddArgument("disable-infobars");
option.AddArgument("window-size=1920,1080");
option.AddArgument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36");
......@@ -101,11 +101,11 @@ namespace TicketSpider.Spiders.ClassInRule
var login = BeginSliderLoginHandler(ref driver);
if (login.IsCompleted)
{
Thread.Sleep(1000 * 5);
//driver.SwitchTo().DefaultContent();
driver.SwitchTo().DefaultContent();
Console.WriteLine($"操作完成,正在等待结果");
VTX.FW.Helper.LogHelper.WriteInfo("RunAsync", $"操作完成,正在等待结果");
//睡眠1秒,等待跳转
Thread.Sleep(5 * 1000);
if (driver.Url.Contains("www.eeo.cn/cn/login"))
{
Console.WriteLine($"模拟登录失败,准备重新执行...");
......@@ -129,9 +129,9 @@ namespace TicketSpider.Spiders.ClassInRule
}
else
{
var cookies = driver.Manage().Cookies.AllCookies;
Thread.Sleep(3 * 1000);
//处理
foreach (var item in cookies)
foreach (var item in driver.Manage().Cookies.AllCookies)
{
_loginCookies += item.Name + "=" + item.Value + ";";
}
......@@ -153,11 +153,8 @@ namespace TicketSpider.Spiders.ClassInRule
{
VTX.FW.Helper.LogHelper.WriteInfo("RunAsync", $"获取cooki失败,{ex.Message}");
Console.WriteLine($"获取cooki失败,{ex.Message}");
Thread.Sleep(1000 * 4);
}
driver.Close();
driver.Quit();
driver.Dispose();
Console.WriteLine("完成登录...");
VTX.FW.Helper.LogHelper.WriteInfo("RunAsync", $"完成登录...");
return flag;
......@@ -199,25 +196,20 @@ namespace TicketSpider.Spiders.ClassInRule
var d1 = Math.Round(bgX * 0.8);
var d2 = Math.Round(bgX * 0.1);
var d3 = Math.Round(bgX * 0.1);
Console.WriteLine("d1:" + d1);
action.MoveByOffset((int)d1, 1);
Thread.Sleep(new Random().Next(100) + 150);
Console.WriteLine("d2:" + d2);
action.MoveByOffset((int)d2, 1);
Thread.Sleep(new Random().Next(100) + 150);
Console.WriteLine("d3:" + d3);
action.MoveByOffset((int)d3, 1);
int last = (bgX - (int)d1 - (int)d2 - (int)d3);
Console.WriteLine("last:" + last);
action.MoveByOffset(last, 1);
action.MoveByOffset((bgX - (int)d1 - (int)d2 - (int)d3), 1);
Thread.Sleep(2000);
#endregion
action.Release(sliderButton);
action.Build().Perform();
driver.SwitchTo().DefaultContent();
}
File.Delete(fileBgPath);
......@@ -251,7 +243,7 @@ namespace TicketSpider.Spiders.ClassInRule
var dirpath = $"{Environment.CurrentDirectory}\\geetest";
Cv2.ImWrite($"{dirpath}\\{DateTime.Now.Ticks}.png", bgImg);
return maxLoc.X - 25;
return maxLoc.X - 20;
}
private static void HeartLine()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment