python硒身份验证专用代理firefox

时间:2018-10-05 02:40:44

标签: python selenium authentication firefox proxy

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.proxy import Proxy
from random import choice
from fake_useragent import UserAgent
import time, re, random, glob
import keyboard

proxy_use= "ip:port"

useragent = UserAgent()
profile = webdriver.FirefoxProfile()
profile.set_preference("intl.accept_languages", "en-US")
profile.set_preference('browser.search.countryCode', 'US')
profile.set_preference("general.useragent.override", useragent.random)
profile.update_preferences()

desired_capability = webdriver.DesiredCapabilities.FIREFOX.copy()
desired_capability["marionette"] = True
desired_capability['proxy'] = {
    'proxyType': "manual",
    'httpProxy': proxy_use,
    'ftpProxy': proxy_use,
    'sslProxy': proxy_use,
    "proxyType":"MANUAL"
        }
queryURL = "https://whatismyipaddress.com"

browser = webdriver.Firefox(firefox_profile=profile,capabilities=desired_capability)
browser.get(queryURL)
keyboard.write("login")
keyboard.press_and_release("tab")
keyboard.write("passwords")
keyboard.press_and_release("enter")
browser.set_page_load_timeout(30)
time.sleep(10)
browser.get("https://whatismyipaddress.com/vpn-comparison")

我可以登录,但是第二个请求中出现错误。错误消息如下。请帮忙。我不能摆脱它。我的英语不好:)

  

回溯(最近通话最近):文件   “ C:\ Users \ alper \ Desktop \ dersler \ calisma.py”,第121行,在       browser.get(“ https://whatismyipaddress.com/vpn-comparison”)文件“ C:\ Users \ alper \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”,   332行,在get中       self.execute(Command.GET,{'url':url})文件“ C:\ Users \ alper \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py ”,   第320行,执行       self.error_handler.check_response(响应)文件“ C:\ Users \ alper \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site-packages \ selenium \ webdriver \ remote \ errorhandler.py”,   第242行,在check_response中       引发exception_class(消息,屏幕,堆栈跟踪)selenium.common.exceptions.NoAlertPresentException:消息:无模式   对话框当前已打开

0 个答案:

没有答案