python自动化打开网页
from selenium.webdriver.firefox.options import Options as FOptions
from selenium.webdriver.chrome.options import Options as Foptions
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.firefox.firefox_profile import FirefoxProfile #firefox设置代理
profile = FirefoxProfile()
# 激活手动代理配置(对应着在 profile(配置文件)中设置首选项)
profile.set_preference("network.proxy.type", 1)
# ip及其端口号配置为 http 协议代理
profile.set_preference("network.proxy.http", "127.0.0.1")
profile.set_preference("network.proxy.http_port", 8080) # 所有协议共用一种 ip 及端口,如果单独配置,不必设置该项,因为其默认为 False
profile.set_preference("network.proxy.share_proxy_settings", True) #chrome设置代理
# options = FOptions() options = FOptions()
chrome_options = webdriver.FirefoxOptions()
chrome_options.add_argument('--proxy-server=http://127.0.0.1:8080')
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('disable-infobars')
browser = webdriver.Firefox(executable_path="D:/geckodriver.exe",firefox_profile=profile) browser.maximize_window()
browser.get('https://account.dianping.com/login?redir=http%3A%2F%2Fwww.dianping.com%2F') button = browser.find_element_by_xpath('/html/body/div/div[2]/div[5]/span')
button.click()
python自动化打开网页的更多相关文章
- Python+selenium打开网页
东西都安装好了,是不是都迫不及待的想要运行一个程序呢? 不过不幸的是,在正式编程打开网页之前,我们还需要做一件事:下载驱动. 据说,在很久之前的selenium1和2中,驱动是被内嵌在selenium ...
- python+selenium实现网页自动化与爬虫技术
举例某购物网站,通过selenium与python,实现主页上商品的搜索,并将信息爬虫保存至本地excel表内. 一.python环境与selenium环境安装 python在官网下载并安装并且设置环 ...
- Python+Selenuim测试网站,只能打开Firefox浏览器却不能打开网页的解决方法
最开始我使用的Selenium版本为2.48,Firefox版本为37,自动化打开网站的时候,可以正常打开. 后来由于Firefox的自检测更新,版本更新为47,导致版本不兼容,自动化打开网站浏览器时 ...
- 【317】python 指定浏览器打开网页 / 文件
一.python 打开浏览器的方法: 1. startfile方法(打开指定浏览器) import os os.startfile("C:\Program Files\internet ex ...
- Python实用案例,Python脚本,Python实现自动监测Github项目并打开网页
往期回顾 Python实现文件自动归类 前言: 今天我们就利用Python脚本实现Github项目的更新,提醒方式是邮箱.直接开整~ 项目地址: https://github.com/kenwoodj ...
- Python HTMLTestRunner生成网页自动化测试报告时中文编码报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6
1. 由于使用Python Selenium做网页自动化测试时,有截取网页上的中文信息保存到测试结果中,最终出现编码错误如下: File "D:/PycharmProjects/AutoTe ...
- python - 将数据转换成 excl 表格, json 等文件 (dajngo - 打开网页后自动下载)
本篇只讲述怎么用. 具体 tablib 更多详细用法可参考博客 : https://blog.csdn.net/liangyuannao/article/details/41476277 # 不得不 ...
- python自动化运维学习第一天--day1
学习python自动化运维第一天自己总结的作业 所使用到知识:json模块,用于数据转化sys.exit 用于中断循环退出程序字符串格式化.format字典.文件打开读写with open(file, ...
- Selenium2+python自动化41-绕过验证码(add_cookie)
前言 验证码这种问题是比较头疼的,对于验证码的处理,不要去想破解方法,这个验证码本来就是为了防止别人自动化登录的.如果你能破解,说明你们公司的验证码吗安全级别不高,那就需要提高级别了. 对于验证码,要 ...
随机推荐
- Linux之搭建远程数据库[Ubuntu:全过程]
1.mariadb在Linux中首次进入mysql (因为此时还没有创建任何用户,mysql的root并不等效于linux中的root用户) sudo apt-get install mysql-se ...
- Python3:OOP Demo
方便快速回顾Python的OOP语法 ###################### # 类的私有专有方法 # ###################### # __init__ : 构造函数,在生成对 ...
- IDEA 在同一目录创建多个项目
以往的Eclipse.NetBeans等开发工具不同,IDEA的Project相当与Eclipse的Workspace,而Module相当于Project. 下边就给出Eclipse与IDEA的概念的 ...
- Spring Cloud 2-Feign 声明式服务调用(三)
Spring Cloud Feign 1. pom.xml 2. application.yml 3. Application.java 4. Client.java 简化RestTemplate调 ...
- .Net Core ----通过XUnit进行接口单元测试(带请求头及参数)并用output输出结果
最近在做core的接口单元测试,所以在这拿出来分享一下,添加XUnit的nuget包 话不多说,直接上代码了: 输出结果(需要的命名空间using Xunit.Abstractions;): ITes ...
- Java_String&StringBuilder&StringBuffer类
目录 一.String类 二."==" 和 "equals"的区别 三.StringBuffer和StringBuilder 一.String类 String为 ...
- [原创]iFPGA-Cable FT2232H JTAG & UART调试器
iFPGA-Cable FT2232H JTAG & UART调试器 [特性] 采用FT2232H,双通道接口: 支持UART: 支持JTAG,Digilent SMT-1,TCK最大时钟频率 ...
- Java List根据对象的某个属性合并list
package com.test; import java.util.ArrayList; import java.util.List; public class FileTest { public ...
- RxJS操作符(二)
一.Observable的性质 三种状态:nex, error, complete 进入到Error状态: ) .filter(val=>{ throw '出错了' }) .take() .re ...
- JavaScript 动态选择方法和属性
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...