python selenium 添加https代理

之前一直在找如何在自动化测试中使用代理,本人比较菜,phantomjs chrome 使用的是普通的http代理都没有问题,当用到https的时候挂掉了。郁闷了3天,后来参考了文档,改用firforx 终于搞掂,记录一下预备以后忘记了

        ip = "127.0.0.1"
	duankou = int(123456)#这里记得类型转换,这坑踩了2天
        profile = webdriver.FirefoxProfile()
	profile.set_preference('network.proxy.type',1)
	profile.set_preference('network.proxy.http',"%s"%ip)
	profile.set_preference('network.proxy.http_port',duankou)
	profile.set_preference('network.proxy.ssl',"%s"%ip)
	profile.set_preference('network.proxy.ssl_port',duankou)
	#profile.set_preference('general.useragent.override',uap)#设置代理头
	profile.update_preferences()
	driver =     webdriver.Firefox(firefox_profile=profile,executable_path=os.getcwd()+'/driver/geckodriver.exe')    

  

转载于:https://www.cnblogs.com/c-shang/p/selenium.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值