A simple toolkit packaged with selenium
The first step is to install the crawler tool:
Enter the install command in the package manager console
Install-Package SeleniumUtil -Version 1.1.0
Then write the code:
using SeleniumUtil;//引入工具包
//BrowserEnum 选择浏览器 isEnableVerboseLogging 启动日志
var data=new CrawlerMain(browser:BrowserEnum.Edge,isEnableVerboseLogging:true);
data.GoToUrl("https://www.baidu.com/");// 访问baidu地址
var wd = data.FindElementsById("kw");//这个是搜索框的id获取到他
wd.SendKeys("Selenium");//然后写入参数到搜索框中
var su = data.FindElementsById("su");//获取搜索按钮
su.Click();//点击他
Thread.Sleep(500);//等待界面加载完成
var content_left = data.FindElementsById("content_left");///获取内容块的id
Console.WriteLine(content_left.Text);//显示内容块的Text内容
Console.ReadKey();
A few lines of code to implement a crawler
There are many other methods in it, you can contact the author for teaching in gitee
Note: Please do not use this tool to make illegal profits on other people's websites. All illegal acts have nothing to do with the plug-in, and the plug-in is only for learning.