业务需要购买http隧道,发现阿布云还行,使用Selenium本来想要用谷歌浏览器的,但是发现不能直接设置账号,所以选用火狐。

按照官方JAVA示例的改编,其中WebDriver实例化不能直接添加FirefoxProfile,所以需要创建一个FirefoxOtions,在这里面添加Profile。

有一个要注意的是,需要引用System.Text.Encoding.CodePages的NuGet包,否则会找不到 Encoding(437) 错误。

参考这个:https://github.com/SeleniumHQ/selenium/issues/4816

代码如下:

            //必须添加这个代码,否则使用Profile报错
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
FirefoxProfile profile = new FirefoxProfile();
// 使用代理
profile.SetPreference("network.proxy.type", );
// 代理服务器配置 ProxyHost-http-dyn.abuyun.com ProxyPort-9020
profile.SetPreference("network.proxy.http", GlobalConf.ProxyHost);
profile.SetPreference("network.proxy.http_port", GlobalConf.ProxyPort);
profile.SetPreference("network.proxy.ssl", GlobalConf.ProxyHost);
profile.SetPreference("network.proxy.ssl_port", GlobalConf.ProxyPort);
       //ProxyUser-通行证书 ProxyPass-通行密钥
profile.SetPreference("username", GlobalConf.ProxyUser);
profile.SetPreference("password", GlobalConf.ProxyPass); // 所有协议公用一种代理配置,如果单独配置,这项设置为false
profile.SetPreference("network.proxy.share_proxy_settings", true); // 对于localhost的不用代理,这里必须要配置,否则无法和webdriver通讯
profile.SetPreference("network.proxy.no_proxies_on", "localhost"); // 以代理方式启动firefox
FirefoxOptions opt = new FirefoxOptions();
opt.Profile = profile;
_firefoxDriver = new FirefoxDriver(GlobalConf.BrowserPath, opt);

C# Selenium FireFox 接入阿布云的更多相关文章

  1. Python3 Scrapy + Selenium + 阿布云爬取拉钩网学习笔记

    1 需求分析 想要一个能爬取拉钩网职位详情页的爬虫,来获取详情页内的公司名称.职位名称.薪资待遇.学历要求.岗位需求等信息.该爬虫能够通过配置搜索职位关键字和搜索城市来爬取不同城市的不同职位详情信息, ...

  2. scrapy——7 scrapy-redis分布式爬虫,用药助手实战,Boss直聘实战,阿布云代理设置

    scrapy——7 什么是scrapy-redis 怎么安装scrapy-redis scrapy-redis常用配置文件 scrapy-redis键名介绍 实战-利用scrapy-redis分布式爬 ...

  3. Selenium2学习-038-firefox、webdriver版本不对称问题解决:org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055

    今天有个朋友在群里问,为何脚本运行不通过,其脚本操作步骤简单描述如下: 1.启动火狐浏览器 2.打开百度 3.查询框输入关键字 4.点击按钮[百度一下] 脚本挺简单的,其给出的应用报错信息如下所示: ...

  4. WebDriver:org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms

    今天尝试最新的webDriver与fireFox搭配: 运行代码时出现如下的问题,但是浏览器却可以打开: org.openqa.selenium.firefox.NotConnectedExcepti ...

  5. TestNG:org.openqa.selenium.firefox.NotConnectedException: Unable to connect

    http://blog.sina.com.cn/s/blog_68f262210102vgzj.html 今天在尝试着用TestNG写一下自动化测试用例,以前也写过,不过用的是经常封装的代码,现在完全 ...

  6. selenium + firefox/chrome/phantomjs登陆之模拟点击

    登陆之模拟点击 工具:python/java + selenium + firefox/chrome/phantomjs (1)windows开发环境搭建 默认已经安装好了firefox 安装pip ...

  7. PHP接入阿里云市场 阿里短信服务DEMO

    阿里短信服务:支持三大运营商短信.智能管道等优质能力,产品特点:3秒可达.99%到达率.超低资费. 使用阿里短信服务步骤: 1.购买服务 到https://market.aliyun.com/prod ...

  8. [Micropython][ESP8266] TPYBoard V202 之MQTT协议接入OneNET云平台

    随着移动互联网的发展,MQTT由于开放源代码,耗电量小等特点,将会在移动消息推送领域会有更多的贡献,在物联网领域,传感器与服务器的通信,信息的收集,MQTT都可以作为考虑的方案之一.在未来MQTT会进 ...

  9. 使用Selenium+firefox抓取网页指定firefox_profile后的问题

    from: https://blog.csdn.net/chufazhe/article/details/51145834 摘要:在使用selenium和firefox抓取网页指定firefox_pr ...

随机推荐

  1. zabbix 邮件报警事件:Zabbix discoverer processes more than 75% busy

    Problem has been resolved at :: on Problem name: Zabbix discoverer processes more than % busy Host: ...

  2. Nginx的软件架构

    nginx原理架构图 Nginx是 master/worker 模型 一个master进程,可生成一个或多个worker进程,每个worker进程基于事件驱动机制响应客户端请求: 事件驱动机制:epo ...

  3. Codeforces Round #344 (Div. 2) 631 B. Print Check (实现)

    B. Print Check time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...

  4. LIS 普及题

    题意 给你一个长度为 \(n\) 的序列 \(a\). 问是否存在一个长度为 \(L\) 的上升子序列,即存在 \(\{x_1,x_2,...,x_L\}(x_1\lt x_2\lt ...\lt x ...

  5. 【CF 718C】fibonacci

    题意 给你一个长度为 \(n\) 的序列 \(a\),有 \(m\) 次操作,操作分两种 \(\text{1}\space \text{l}\space \text{r}\space \text{x} ...

  6. 手摸手带你实现 小游戏<别踩白块儿 -- 内有游戏链接>

    别踩白块儿 使用(白鹭引擎)Egret编写的游戏 游戏地址 准备工作 了解白鹭引擎 并安装编写工具 安装游戏引擎 安装Egret Wing3 创建项目 创建项目可以选择不同版本的引擎,创建成功之后还可 ...

  7. vue中前进刷新、后退缓存方案收集

    来源掘金: https://juejin.im/post/5b2ce07ce51d45588a7dbf76 来源博客园 https://www.cnblogs.com/wonyun/p/8763314 ...

  8. 从hive中读取数据推送到kafka

    由python2.7语言实现的,包也比较旧了. # -*- coding: utf-8 -*- # Version: 1.0.0 # Description: py_Hive2Kafka2kafka ...

  9. hiho #1308 : 搜索二·骑士问题

    #1308 : 搜索二·骑士问题 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi:小Ho你会下国际象棋么? 小Ho:应该算会吧,我知道每个棋子的移动方式,马走日象 ...

  10. AOP 实现日志

    package com.foen.foensys.config; import com.alibaba.fastjson.JSON;import com.foen.foensys.model.SysL ...