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. 数组filter方法对数组元素进行过滤

    Array.prototype.filter对数组中元素进行过滤 /** * @method reduce * @param {number} item 当前迭代的数组元素 * @param {num ...

  2. java 线程排查问题流程

    1. 通过top命令查看当前系统CPU使用情况,定位CPU使用率超过100%的进程ID:2. 通过ps aux | grep PID命令进一步确定具体的线程信息:3. 通过ps -mp pid -o ...

  3. 【Sliding Window】单调队列

    题目描述 给你一个长度为 N 的数组,一个长为 K 的滑动的窗体从最左移至最右端,你只能见到窗口的 K 个整数,每次窗体向右移动一位,如下表:

  4. Cordova-Android-Android target:not installed

    原文:Cordova-Android-Android target:not installed 运行cordova requirements检查是否具备使用 Cordova 开发/运行 Android ...

  5. iOS RunLoop了解和使用

    RunLoop介绍和使用 上次讲了runtime,这次是runloop,虽然两者都是run开头的名词术语,但是在OC中,这两个东西压根没啥联系.这篇文章主要讲讲runloop的一些概念和用法.其中包含 ...

  6. poj 3090 Visible Lattice Points 法利系列||通过计

    因为图像关于对角线对称.所以我们仅仅看下三角区域. 将x轴看做分母,被圈的点看成分子 依次是{1/2},{1/3,1/2},{1/4,3/4},{1/5,2/5,3/5,4/5} 写成前缀和的形式就是 ...

  7. 我的MBTI职业性格测试

    背景 最近在看<程序员的思维训练--开发人之前能的九堂课>,其中讲到了 MBTI 职业性格测试的指导意义.记起来两年多以前在面试 ASES 的时候有做过这个测试,只可惜当时的测试结果在好几 ...

  8. 图像块的访问(填充 padding,步长 stride,窗 Window/kernel/filter)

    无填充是有填充的特例(填充为 1). utilities(matlab)-- 图像分块(image2cols.cols2image)(未填充) 1. 一个图像块 ⇒ 返回一个值 输出矩阵的大小: ou ...

  9. 将 WPF、UWP 以及其他各种类型的旧 csproj 迁移成基于 Microsoft.NET.Sdk 的新 csproj

    原文 将 WPF.UWP 以及其他各种类型的旧 csproj 迁移成基于 Microsoft.NET.Sdk 的新 csproj 写过 .NET Standard 类库或者 .NET Core 程序的 ...

  10. 关于提高UDP发送效率的方法

    UDP的发送效率和什么因素有关呢? 直观觉得,UDP的切包长越大,应该发送效率越高(最长为65536).可是依据实际測试和在网上查到的资料的结果,包长度为1024为发送效率最高. 这样的结果让人感到疑 ...