C# dotnetcore2.0结合Selenium搜索网页
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搜索网页的更多相关文章
- Python3 Selenium WebDriver网页的前进、后退、刷新、最大化、获取窗口位置、设置窗口大小、获取页面title、获取网页源码、获取Url等基本操作
Python3 Selenium WebDriver网页的前进.后退.刷新.最大化.获取窗口位置.设置窗口大小.获取页面title.获取网页源码.获取Url等基本操作 通过selenium webdr ...
- Python实训day07pm【Selenium操作网页、爬取数据-下载歌曲】
练习1-爬取歌曲列表 任务:通过两个案例,练习使用Selenium操作网页.爬取数据.使用无头模式,爬取网易云的内容. ''' 任务:通过两个案例,练习使用Selenium操作网页.爬取数据. 使用无 ...
- WEBUS2.0 In Action - 搜索操作指南 - (1)
上一篇:WEBUS2.0 In Action - 索引操作指南(2) | 下一篇:WEBUS2.0 In Action - 搜索操作指南(2) 1. IQueriable中内置的搜索功能 在Webus ...
- WEBUS2.0 In Action - 搜索操作指南 - (2)
上一篇:WEBUS2.0 In Action - 搜索操作指南(1) | 下一篇:WEBUS2.0 In Action - 搜索操作指南(3) 2. 使用Query Query是所有查询的基类, 它一 ...
- WEBUS2.0 In Action - 搜索操作指南 - (3)
上一篇:WEBUS2.0 In Action - 搜索操作指南(2) | 下一篇:WEBUS2.0 In Action - 搜索操作指南(4) 3. 评分机制 (Webus.Search.IHitSc ...
- WEBUS2.0 In Action - 搜索操作指南 - (4)
上一篇:WEBUS2.0 In Action - 搜索操作指南(3) 6. 搜索多个索引 为了提升性能, 我们可以从多个索引同时进行搜索, Webus.Search.MultiSearcher提供了相 ...
- 记一个Selenium自动化测试网页
今天想跟大家分享的是Selenium自动化测试网页,就是关于selenium的自动化测试一些基础的东西,如有不对的地方请多多指教. 一.安装环境 1.Python环境 安装完成后通过Windows命令 ...
- Selenium 定位网页元素
第一 定位元素辅助工具 IE中在元素上右击 -> “检查元素”,或按F12键打开开发者工具: Chrome中在元素上右击 -> “审查元素”,或按F12键打开开发者工具: Firefox ...
- Python selenium自动化网页抓取器
(开开心心每一天~ ---虫瘾师) 直接入正题---Python selenium自动控制浏览器对网页的数据进行抓取,其中包含按钮点击.跳转页面.搜索框的输入.页面的价值数据存储.mongodb自动i ...
随机推荐
- Activity“ 阻止自动弹出软键盘”的方法 -尤其是对于Tab页下的!
我的activity是Tab页签下的~! 所以应把代码加在继承于TabActivity的那个activity中!!而不是由点击Tab页启动的那个activity <activity androi ...
- IDEA多模块父子依赖maven项目war包部署
IDEA多模块父子依赖maven项目war包部署 Posted on 2018-04-25 | In IDEA | | Visitors 286 IDEA全称为IntrlliJ IDEA,它是一款非常 ...
- Apache DataFu: LinkedIn开源的Pig UDF库
介绍 Apache DataFu分两部分,本文介绍的是其Pig UDF的部分.代码在Github上开源(除了代码外.也有一些slides介绍链接). DataFu里面是一些Pig的UDF.主要包含这些 ...
- 配置SVN服务器
svn启动: 版本控制对于团队合作显得尤为重要,那么如何在iOS开发中进行版本控制呢?在今天的博客中将会介绍如何在MAC下配置SVN服务器,如何导入我们的工程,如何在Xcode中进行工程的checkO ...
- 数码测色计获取UIColor的RGB
1.打开电脑数码测色计 2.鼠标移动到需要的颜色上 3.获取相应RGB值: [UIColor colorWithRed:204.f/255.f green:0.f/255.f blue:212.f/2 ...
- NOIP模拟 Work - 二分 + 树状数组 / ???
题目分析 如果没有最后的注意事项,此题就是二分裸题.有了注意事项,会有两种思路: 在线:二分天数t,并在主席树上求1~t天中大于d(浪费的时间)的时间之和以及数量,答案即为:sum - d * cnt ...
- 常见排序算法(java实现)
常见排序算法介绍 冒泡排序 代码: public class BubbleSort { public static void sort(int[] array) { int tValue; for ( ...
- 微信小程序之 满意度
话不多说,我们来看一下效果图: 要实现的效果:点击到第几颗星,就要显示到第几颗星, 接下来直接查看源码: <view class="l-evalbox row"> &l ...
- python request 代理/超时/证书
import requests headers = { "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) A ...
- android tips—开机引导启动wifi设置
在开机引导(Setupwizard,Guide)中都有关于wifi设置项,我得做法例如以下: Intent intent = new Intent(); intent.setClassName(&qu ...