using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace ConsoleApp_Selenium
{
class Program
{
static void Main(string[] args)
{ ChromeDriver cd = new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory.ToString()); cd.Navigate().GoToUrl("http://chart.icaile.com/sd11x5.php");
string text = cd.FindElementById("fixedtable").Text; cd.Quit();
Console.WriteLine(text);
Console.Read();
}
}
}

  

nuget安装

find-package selenium

install-package Selenium.WebDriver

install-package Selenium.WebDriver.ChromeDriver

使用headless chrome这样就没有界面。

using System;
using OpenQA.Selenium.Chrome;
namespace ConsoleApp_Selenium
{
class Program
{
static void Main(string[] args)
{
ChromeOptions op = new ChromeOptions();
op.AddArguments("--headless");
op.AddArguments("--window-size=1920,1080");
ChromeDriver cd = new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory.ToString(),op);
cd.Navigate().GoToUrl("http://chart.icaile.com/sd11x5.php");
string text = cd.FindElementById("fixedtable").Text;
cd.Quit();
Console.WriteLine(text);
Console.Read();
}
}
}

  

下面是使用PhantomJS

nuget 安装> install-package Selenium.PhantomJS.WebDriver

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.PhantomJS;
namespace ConsoleApp_Selenium
{
class Program
{
static void Main(string[] args)
{
PhantomJSOptions po = new PhantomJSOptions();
po.AddAdditionalCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0");
PhantomJSDriver cd = new PhantomJSDriver(AppDomain.CurrentDomain.BaseDirectory.ToString(), po); cd.Navigate().GoToUrl("http://chart.icaile.com/sd11x5.php");
string text = cd.FindElementById("fixedtable").Text; cd.Quit();
Console.WriteLine(text);
Console.Read();
}
}
}

  

C# dotnetcore2.0结合Selenium搜索网页的更多相关文章

  1. Python3 Selenium WebDriver网页的前进、后退、刷新、最大化、获取窗口位置、设置窗口大小、获取页面title、获取网页源码、获取Url等基本操作

    Python3 Selenium WebDriver网页的前进.后退.刷新.最大化.获取窗口位置.设置窗口大小.获取页面title.获取网页源码.获取Url等基本操作 通过selenium webdr ...

  2. Python实训day07pm【Selenium操作网页、爬取数据-下载歌曲】

    练习1-爬取歌曲列表 任务:通过两个案例,练习使用Selenium操作网页.爬取数据.使用无头模式,爬取网易云的内容. ''' 任务:通过两个案例,练习使用Selenium操作网页.爬取数据. 使用无 ...

  3. WEBUS2.0 In Action - 搜索操作指南 - (1)

    上一篇:WEBUS2.0 In Action - 索引操作指南(2) | 下一篇:WEBUS2.0 In Action - 搜索操作指南(2) 1. IQueriable中内置的搜索功能 在Webus ...

  4. WEBUS2.0 In Action - 搜索操作指南 - (2)

    上一篇:WEBUS2.0 In Action - 搜索操作指南(1) | 下一篇:WEBUS2.0 In Action - 搜索操作指南(3) 2. 使用Query Query是所有查询的基类, 它一 ...

  5. WEBUS2.0 In Action - 搜索操作指南 - (3)

    上一篇:WEBUS2.0 In Action - 搜索操作指南(2) | 下一篇:WEBUS2.0 In Action - 搜索操作指南(4) 3. 评分机制 (Webus.Search.IHitSc ...

  6. WEBUS2.0 In Action - 搜索操作指南 - (4)

    上一篇:WEBUS2.0 In Action - 搜索操作指南(3) 6. 搜索多个索引 为了提升性能, 我们可以从多个索引同时进行搜索, Webus.Search.MultiSearcher提供了相 ...

  7. 记一个Selenium自动化测试网页

    今天想跟大家分享的是Selenium自动化测试网页,就是关于selenium的自动化测试一些基础的东西,如有不对的地方请多多指教. 一.安装环境 1.Python环境 安装完成后通过Windows命令 ...

  8. Selenium 定位网页元素

    第一 定位元素辅助工具 IE中在元素上右击 ->  “检查元素”,或按F12键打开开发者工具: Chrome中在元素上右击 -> “审查元素”,或按F12键打开开发者工具: Firefox ...

  9. Python selenium自动化网页抓取器

    (开开心心每一天~ ---虫瘾师) 直接入正题---Python selenium自动控制浏览器对网页的数据进行抓取,其中包含按钮点击.跳转页面.搜索框的输入.页面的价值数据存储.mongodb自动i ...

随机推荐

  1. 【hdu 2594】Simpsons’ Hidden Talents

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...

  2. TensorFlow 实现深度神经网络 —— Denoising Autoencoder

    完整代码请见 models/DenoisingAutoencoder.py at master · tensorflow/models · GitHub: 1. Denoising Autoencod ...

  3. 找不到头文件xxxxx.h file not found

    项目里有该文件,但是还是显示找不到.或者是cocopods打开的项目. 原因:.h文件路径找不到.具体找不到的原因有很多种. 1.一般会设置 IOS引用三方framewrok的头文件出现'xxxxx/ ...

  4. echarts多条折线图和柱状图实现

    参考链接:echarts官网:http://echarts.baidu.com/原型图(效果图): 图片.png 代码: <!DOCTYPE html> <html> < ...

  5. Vue中import '@...'是什么

    今天看新项目代码,有import '@/assets/css/theme/index.css'一类的代码,里面的@是做什么的呢.   找到这篇文章https://www.cnblogs.com/bos ...

  6. ubuntu 16.0.4 中docker 部署 sqlserver 2017(四)

    1. 从 Docker Hub 中拉出 SQL Server 2017 Linux 容器映像 sudo docker pull mcr.microsoft.com/mssql/server:2017- ...

  7. 一个封装了的选项卡效果js

    转载自:http://www.cnblogs.com/skyblue/archive/2008/04/26/1171968.html <!DOCTYPE HTML PUBLIC "-/ ...

  8. 避免单线程单元 (STA) COM 组件

    默认情况下,ASP.NET 不允许任何 STA COM 组件在页面内运行.若要运行它们,必须在 .aspx 文件内将 ASPCompat=true 属性包含在 @ Page 指令中.这样就将执行用的线 ...

  9. zabbix从听说到学会

    一.zabbix简介 zabbix(音同 zæbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供 ...

  10. 理解 t-SNE (Python)

    t-SNE(t-distribution Stochastic Neighbor Embedding)是目前最为流行的高维数据的降维算法. t-SNE 成立的前提基于这样的一个假设:我们现实世界观察到 ...