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();
}
}
}

  

最新文章

  1. WCF之net.tcp
  2. backup, file manipulation operations (such as ALTER DATABASE ADD FILE) and encryption changes on a database must be serialized.
  3. php : 常用函数
  4. Linux下如何修改Apache根目录
  5. [IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets
  6. C++基础笔记(三)C++面向对象
  7. QEMU 使用的镜像文件:qcow2 与 raw
  8. BZOJ 3983 Takeover Wars 解题报告
  9. php 多维数组转换
  10. Twemproxy 分布式集群缓存代理服务器
  11. php代码审计--sql注入
  12. python内置函数与匿名函数
  13. Python全栈-day4-语法基础2
  14. Linux学习10-CentOS搭建nginx负载均衡环境
  15. Android开发之ActionBar
  16. action spring 注入错误,如果检查各项注入都没有错误时,考虑struts 是否配置了namespace(如果你有多个namespace="/")
  17. Python----一些面试题
  18. Python 函数 -hasattr()
  19. numpy.random.random & numpy.ndarray.astype & numpy.arange
  20. pL/SQL 创建DBLIKN

热门文章

  1. [Ramda] Curry and Uncurry Functions with Ramda
  2. sublime-1 sublime设置到鼠标右键
  3. 百度消息推送SDK探究(并附上最简推送Demo)
  4. Role-based access control modeling and auditing system
  5. 快来看看Google出品的Protocol Buffer,别仅仅会用Json和XML了
  6. 要求两个异步任务都完成后, 才能回到主线程:dispatch_group_t
  7. 过滤Filter推断用户是否登录
  8. java中unicode utf-8以及汉字之间的转换工具类
  9. Notepad++中删除连续的任意n行
  10. 打开一个很好的介绍Lucene4 FST文章