当前位置: 首页 > wzjs >正文

网页模板哪个网站可以下载百度上做优化

网页模板哪个网站可以下载,百度上做优化,传媒公司名字大全,废旧建筑模板多少钱一吨BitComet GreenLight,内网黄灯转绿灯 (HighID), 增加p2p连接率提速下载-CSDN博客 前两天写个这个,每次开机关机后要重来一遍很麻烦的索性写个自动化。 先还是按照上面的教程自己制作一遍,留下Luck 以及 路由器相关的 端口记录信息。 (因为自…

BitComet GreenLight,内网黄灯转绿灯 (HighID), 增加p2p连接率提速下载-CSDN博客
前两天写个这个,每次开机关机后要重来一遍很麻烦的索性写个自动化。


先还是按照上面的教程自己制作一遍,留下Luck 以及 路由器相关的 端口记录信息。

(因为自动化我没写创建的逻辑,只是写了更改端口号的逻辑,所以基础信息条目需要存在。)

基于更改信息,自动化主要逻辑如下

1、取得Luck 设定好的端口

2、复制到路由器相关端口映射页面保存

3、启动BT,设置新的端口映射数据


完整代码如下:

 public class NetworkManagerExt{private string HostPort { get; set; }private string RemotePort { get; set; }private const string BitCometPath = @"D:\Program Files\BitComet\BitComet.exe";private const string LuckyPath = @"D:\Lucky\lucky.exe";private const string RouterUrl = "http://192.168.0.1/";private const string RouterPassword = "你自己的密码";private const string LuckyUrl = "http://127.0.0.1:16601/#/login";private const string LuckyPassword = "666"; //luck 默认密码private const int DefaultTimeoutSeconds = 30;public void ConfigureNetwork(){StartLuckyAndConfigureRouter();}public void StartBitComet(){if (!string.IsNullOrEmpty(RemotePort)){ConfigureBitComet(RemotePort);}else{Console.WriteLine("Error: RemotePort not set. Cannot configure BitComet.");}}private Process GetOrStartProcess(string exePath){string processName = System.IO.Path.GetFileNameWithoutExtension(exePath);Process[] processes = Process.GetProcessesByName(processName);return processes.Length > 0 ? processes[0] : Process.Start(exePath);}private void ConfigureBitComet(string port){Process calc = Process.Start(BitCometPath);AutomationElement mainExe = null;// 等待BitComet窗口出现DateTime startTime = DateTime.Now;TimeSpan timeout = TimeSpan.FromSeconds(DefaultTimeoutSeconds);while (mainExe == null){if (DateTime.Now - startTime > timeout){throw new TimeoutException("Timeout waiting for BitComet window to appear");}AutomationElementCollection elementCollection = AutomationElement.RootElement.FindAll(TreeScope.Children,new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window));foreach (AutomationElement item in elementCollection){if (item.Current.Name.Contains("BitComet", StringComparison.OrdinalIgnoreCase)){mainExe = item;break;}}if (mainExe == null){System.Threading.Thread.Sleep(500); // 短暂等待后重试}}WindowPattern windowPattern = (WindowPattern)mainExe.GetCurrentPattern(WindowPattern.Pattern);windowPattern.SetWindowVisualState(WindowVisualState.Normal);System.Windows.Forms.SendKeys.SendWait("^p");bool setOperated = false;startTime = DateTime.Now;while (!setOperated){if (DateTime.Now - startTime > timeout){throw new TimeoutException("Timeout waiting for BitComet settings dialog");}var tempWindow = mainExe.FindFirst(TreeScope.Children,new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window));if (tempWindow != null){var tempPane = tempWindow.FindFirst(TreeScope.Subtree,new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));var onButtonPane = tempWindow.FindFirst(TreeScope.Children,new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button));if (tempPane != null){ValuePattern valuePattern = (ValuePattern)tempPane.GetCurrentPattern(ValuePattern.Pattern);valuePattern.SetValue(port);setOperated = true;InvokePattern invokePattern = (InvokePattern)onButtonPane.GetCurrentPattern(InvokePattern.Pattern);invokePattern.Invoke();}}if (!setOperated){System.Threading.Thread.Sleep(500); // 短暂等待后重试}}}private void StartLuckyAndConfigureRouter(){Process calc = GetOrStartProcess(LuckyPath);AutomationElement mainExe = null;// 等待Lucky窗口出现DateTime startTime = DateTime.Now;TimeSpan timeout = TimeSpan.FromSeconds(DefaultTimeoutSeconds);while (mainExe == null){if (DateTime.Now - startTime > timeout){throw new TimeoutException("Timeout waiting for Lucky window to appear");}var element = AutomationElement.RootElement.FindFirst(TreeScope.Subtree,new PropertyCondition(AutomationElement.NameProperty, "万吉"));if (element != null){mainExe = element;}else{System.Threading.Thread.Sleep(500); // 短暂等待后重试}}using (IWebDriver driver = new EdgeDriver()){// 设置隐式等待,适用于所有元素查找driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);// 创建显式等待对象WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(DefaultTimeoutSeconds));// 登录Luckydriver.Navigate().GoToUrl(LuckyUrl);// 等待输入框出现并输入密码var inputElements = wait.Until(d => d.FindElements(By.CssSelector("input[placeholder='默认666']")));foreach (var item in inputElements){item.Clear();item.SendKeys(LuckyPassword);}// 等待登录按钮出现并点击IWebElement loginButton = wait.Until(d => {var button = d.FindElement(By.CssSelector("button.el-button.el-button--primary.is-round"));return button.Text == "登录" ? button : null;});loginButton.Click();// 获取端口信息driver.Navigate().GoToUrl("http://127.0.0.1:16601/#/stun");// 等待第一个IP端口信息出现IWebElement firstIpSpan = wait.Until(d => d.FindElement(By.XPath("/html/body/div[1]/div/section/section/section/main/div/div/div[1]/div/div[1]/div[1]/div[1]/div/div/div/div/table/tbody/tr[2]/td[2]/span[1]/span")));// 等待第二个IP端口信息出现IWebElement secondIpSpan = wait.Until(d => d.FindElement(By.XPath("/html/body/div[1]/div/section/section/section/main/div/div/div[1]/div/div[1]/div[1]/div[1]/div/div/div/div/table/tbody/tr[2]/td[2]/span[3]/span")));string firstIpPort = firstIpSpan.Text;string secondIpPort = secondIpSpan.Text;if (!string.IsNullOrEmpty(firstIpPort) && !string.IsNullOrEmpty(secondIpPort)){HostPort = firstIpPort.Split(':')[1];RemotePort = secondIpPort.Split(':')[1];// 配置路由器ConfigureRouter(driver, wait);}}}private void ConfigureRouter(IWebDriver driver, WebDriverWait wait){driver.Navigate().GoToUrl(RouterUrl);// 等待密码输入框出现IWebElement routerPwd = wait.Until(d => d.FindElement(By.XPath("/html/body/div[6]/div[2]/ul/li[2]/ul/li[1]/input")));routerPwd.Clear();routerPwd.SendKeys(RouterPassword);// 等待登录按钮出现并点击IWebElement loginButton = wait.Until(d => d.FindElement(By.XPath("/html/body/div[6]/div[2]/ul/li[3]/input")));loginButton.Click();// 等待功能1按钮出现并点击IWebElement func1 = wait.Until(d => d.FindElement(By.XPath("/html/body/div[3]/div[2]/div[2]/ul/li[3]/div/i[2]")));func1.Click();// 等待功能2按钮出现并点击IWebElement func2 = wait.Until(d => d.FindElement(By.XPath("/html/body/div[3]/div[2]/div[1]/div[3]/div[2]/div[1]/div/div[2]/div[1]/div[8]/div/div/input[3]")));func2.Click();// 等待功能3按钮出现并点击IWebElement func3 = wait.Until(d => d.FindElement(By.XPath("/html/body/div[3]/div[2]/div[1]/div[3]/div[2]/div[1]/div[2]/div/div[3]/table/tbody/tr[2]/td[7]/i")));func3.Click();// 设置外部端口IWebElement outport = wait.Until(d => d.FindElement(By.XPath("/html/body/div[3]/div[2]/div[1]/div[3]/div[2]/div[1]/div[2]/div/div[3]/table/tbody/tr[2]/td[3]/input")));outport.Clear();outport.SendKeys(HostPort);// 设置内部端口IWebElement selfport = wait.Until(d => d.FindElement(By.XPath("/html/body/div[3]/div[2]/div[1]/div[3]/div[2]/div[1]/div[2]/div/div[3]/table/tbody/tr[2]/td[4]/input")));selfport.Clear();selfport.SendKeys(RemotePort);// 保存路由器设置IWebElement saveButton = wait.Until(d => d.FindElement(By.XPath("/html/body/div[3]/div[2]/div[1]/div[3]/div[2]/div[1]/div[2]/div/div[3]/table/tbody/tr[2]/td[7]/input[1]")));saveButton.Click();}}

路由器 Web 部分(ConfigureRouter()方法),需要自行Web 页面 元素 XPath 取得慢慢调整,我的路由器是 TPLink ,TL-WDR8500,配置界面大致如下:

调用代码
 

   static void Main(string[] args){var networkManager = new NetworkManagerExt();networkManager.ConfigureNetwork();networkManager.StartBitComet();}

这样 每次开机执行一下这个exe,保障BT 是绿灯,前面配置设置那些步骤全自动化。

需要的包和引用如下:(基于 .net 9.0 编译通过,测试通过)

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net9.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><ApplicationManifest>app.manifest</ApplicationManifest></PropertyGroup><ItemGroup><FrameworkReference Include="Microsoft.WindowsDesktop.App" /><PackageReference Include="Selenium.WebDriver" Version="4.29.0" /></ItemGroup>
</Project>



 

http://www.dtcms.com/wzjs/468578.html

相关文章:

  • 大做网站公司关键词seo
  • 微信公众平台开发实例教程东莞seo优化排名
  • 2018网站的建设与维护前景网站关键词优化价格
  • 毕业设计购物网站怎么做怎么自己做一个网站平台
  • 怎么在阿里巴巴网站做公司名称云搜索下载
  • 帮站seo武汉seo关键词排名优化
  • 电脑上如何进入wordpressseo推广和百度推广的区别
  • 深圳网站建设创想营销博客推广的方法与技巧
  • 广州旅游网站建设设计如何做网页链接
  • 广州有哪些网络设计公司seo外包公司是啥
  • 做外贸的网站要多少钱网页代码模板
  • 如何夸奖客户网站做的好aso优化服务站
  • 做有支付系统的网站一般需要多少钱网页搜索引擎优化技术
  • 企业网站诊断与优化方案seo中文含义是什么
  • 建设一个网站需要哪方面的费用周口网站建设公司
  • 网站开发收最新seo自动优化软件
  • 免费网页在线代理服务器南昌网站优化公司
  • 云南建筑工程网搜索引擎seo关键词优化效果
  • 家居建材网站源码艺人百度指数排行榜
  • 沧州做网站优化哪家公司便宜免费引流推广方法
  • 一个jsp做的购物小网站如何免费建立一个网站
  • 慈善机构网站建设报价网络推广员上班靠谱吗
  • 怎么建个人网页seo推广岗位职责
  • 无锡做网站首选众诺网络营销的基本功能
  • 做征婚网站郑州seo优化培训
  • 建设个人网站流程营销软件网
  • ps做设计想接私活在什么网站seo课程培训要多少钱
  • 建购物网站的详细步骤电子技术培训机构
  • php培训机构企业做网站对网站外部的搜索引擎优化
  • wordpress 调用二级分类seo专员是干什么的