Commit 23f418ea authored by 黄奎's avatar 黄奎

登录算法调整

parent e9a8ac49
......@@ -264,29 +264,45 @@ namespace TicketSpider.Spiders.ClassInRule
{
Directory.CreateDirectory(dirpath);
}
driver.SwitchTo().Frame(driver.FindElement(By.Id("tcaptcha_iframe")));
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById(\"slideBlock\").style.display = 'none';");
//获取验证码弹窗
driver.SwitchTo().Frame(driver.FindElement(By.Id("tcaptcha_iframe_dy")));
//获取背景图
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementsByClassName(\"tc-fg-item\")[0].style.display = 'none';document.getElementsByClassName(\"tc-fg-item\")[1].style.display = 'none';document.getElementsByClassName(\"tc-fg-item\")[2].style.display = 'none';");
var bgPng = ((ITakesScreenshot)driver.FindElement(By.Id("slideBg"))).GetScreenshot();
var fileBgPath = $"{dirpath}\\{DateTime.Now.Ticks}.png";
bgPng.SaveAsFile(fileBgPath, ScreenshotImageFormat.Png);
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById(\"slideBlock\").style.display = 'block';document.getElementById(\"slideBg\").style.opacity = 0;");
var blockPng = ((ITakesScreenshot)driver.FindElement(By.Id("slideBlock"))).GetScreenshot();
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById(\"slideBg\").style.opacity = 1;");
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementsByClassName(\"tc-fg-item\")[0].style.display = 'block';document.getElementsByClassName(\"tc-fg-item\")[1].style.display = 'block';document.getElementsByClassName(\"tc-fg-item\")[2].style.display = 'block';");
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById(\"slideBg\").style.display = 'none';");
var blockElements= driver.FindElements(By.ClassName("tc-fg-item"));
var fileBlockPath = $"{dirpath}\\{DateTime.Now.Ticks }__1.png";
blockPng.SaveAsFile(fileBlockPath, ScreenshotImageFormat.Png);
if (blockElements != null && blockElements.Count == 3)
{
int index = 0;
foreach (var item in blockElements)
{
if (index == blockElements.Count - 2)
{
var fileBlockPath2 = $"{dirpath}\\{DateTime.Now.Ticks }__{index}.png";
var blockPng = ((ITakesScreenshot)item).GetScreenshot();
blockPng.SaveAsFile(fileBlockPath, ScreenshotImageFormat.Png);
}
index++;
}
}
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById(\"slideBg\").style.display = 'block';");
var bgX = FireFoxGetBoundary(fileBgPath, fileBlockPath);
InfoHelper.WriteLine($"读取背景缺口边界X坐标: {bgX}");
VTX.FW.Helper.LogHelper.WriteInfo("BeginSliderLoginHandler", $"读取背景缺口边界X坐标: {bgX}");
Actions action = new(driver);
var sliderButton = driver.FindElement(By.Id("tcaptcha_drag_button"));
var sliderButton = driver.FindElement(By.ClassName("tc-slider-normal"));
if (sliderButton != null)
{
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById(\"slideBlock\").style.opacity = 1;");
//((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById(\"slideBlock\").style.opacity = 1;");
action.ClickAndHold(sliderButton).Build().Perform();
#region 开始拟人移动
var d1 = Math.Round(bgX * 0.8);
......@@ -336,9 +352,9 @@ namespace TicketSpider.Spiders.ClassInRule
Cv2.Rectangle(bgImg, maxLoc, bt, Scalar.Red, 2);
string newImage = $"{dirpath}\\{DateTime.Now.Ticks}_NewBg.png";
Cv2.ImWrite(newImage, bgImg);
File.Delete(fileBgPath);
File.Delete(fileBlockPath);
File.Delete(newImage);
//File.Delete(fileBgPath);
//File.Delete(fileBlockPath);
//File.Delete(newImage);
return maxLoc.X - 20;
}
......
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