Home python selenium python proxy does not work page

selenium python proxy does not work page

Author

Date

Category

Learning Selenium is this code:

print ("Enter the name without .txt")
TXTER = INPUT ("Enter where to take passwords and logins and so on:")
TXT = TXTER + '. TXT'
F = OPEN (TXT)
User_Agent = F.ReadLine ()
If User_Agent == "\ n":
  Print ("Enter User-Agent to File")
ELSE:
  Print (")
  ninja = user_Agent
proxy_host = f.ReadLine ()
if proxy_host == "\ n":
  Print ("It seems I have to work without a proxy ...")
  Option = WebDriver.firefoxoptions ()
  option.set_preference ("Dom.WebDriver.Enabled", False)
  option.set_preference ("general.useragent.Ordride", Ninja)
  Driver = WebDriver.Firefox (options = option)
ELSE:
  Print ("It seems I have to work with a proxy ...")
  proxy_port = F.ReadLine ()
  proxy_login = F.ReadLine ()
  proxy_password = F.ReadLine ()
  IF proxy_login == "\ n":
    Print ("It seems no login from proxy ...")
    Print ("Do not advise you to use free proxy!")
    if proxy_password == "\ n":
      Print ("It seems no password from proxy ...")
      Proxy_Host = proxy_Host.
      Proxy_Port = proxy_port.
      FP = WebDriver.firefoxProfile ()
      FP.SET_PREFERENCE ('Network.Proxy.Type', 1)
      FP.SET_PREFERENCE ('Network.Proxy.http', Proxy_Host)
      FP.SET_PREFERENCE ('Network.Proxy.http_port', Proxy_Port)
      FP.Set_Preference ('Network.Proxy.https', Proxy_Host)
      FP.Set_Preference ('Network.Proxy.https_PORT', Proxy_Port)
      FP.Set_Preference ('Network.Proxy.ftp', Proxy_Host)
      FP.Set_Preference ('Network.Proxy.ftp_Port', Proxy_Port)
      FP.SET_PREFERENCE ('Network.Proxy.ssl', Proxy_Host)
      FP.SET_PREFERENCE ('Network.Proxy.ssl_Port', Proxy_Port)
      FP.Set_Preference ('Network.Proxy.no_Proxies_on', '')
      Option = WebDriver.firefoxoptions ()
      option.set_preference ("Dom.WebDriver.Enabled", False)
      option.set_preference ("general.useragent.Ordride", Ninja)
      Driver = WebDriver.firefox (options = option, Firefox_Profile = Fp)
    ELSE:
      Print ("Something is wrong here!")
      sys.exit ()
  ELSE:
    proxy_options = {
      "Proxy": {
        "https": f "http: // {proxy_login}: {proxy_password} @" + proxy_host + ":" + proxy_port
      }
    }
    Option = WebDriver.firefoxoptions ()
    option.set_preference ("Dom.WebDriver.Enabled", False)
    option.set_preference ("general.useragent.Ordride", Ninja)
    Driver = WebDriver.firefox (options = option, seleniumwire_options = proxy_options)
    Print ("OK")
    Driver.get ('https://browser-info.ru/')

When moving, writes this:

And in CMD writes:

traceback (most recent call last):
 File "Ibot.py", Line 604, in & lt; Module & gt;
  MENU ()
 File "Ibot.py", Line 157, in Menu
  Driver.get ('https://browser-info.ru/')
 File "C: \ Python \ Lib \ Site-Packages \ Selenium \ WebDriver \ Remote \ WebDriver.py", Line 333, In Get
  Self.Execute (Command.get, {'URL': URL})
 File "C: \ Python \ Lib \ Site-Packages \ Selenium \ WebDriver \ Remote \ WebDriver.py", Line 321, In Execute
  Self.error_Handler.Check_Response (Response)
 File "C: \ Python \ Lib \ Site-Packages \ Selenium \ WebDriver \ Remote \ ErrorHandler.py", Line 242, In Check_Response
  RAISE EXCEPTION_CLASS (Message, Screen, Stacktrace) 
Selenium.common.Exceptions.WebDriverException: Message: REACHED ERROR Page: About: neterror? E = Redirectloop & amp; u = https% 3a // browser-info.ru / & amp; c = utf-8 & amp; d = firefox% 20% D0 % BE% D0% BF% D1% 80% D0% B5% D0% B4% D0% B5% D0% BB% D0% B8% D0% BB% 2C% 20% D1% 87% D1% 82% D0% BE % 20% D1% 81% D0% B5% D1% 80% D0% B2% D0% B5% D1% 80% 20% D0% BF% D0% B5% D1% 80% D0% B5% D0% BD% D0 % B0% D0% BF% D1% 80% D0% B0% D0% B2% D0% BB% D1% 8F% D0% B5% D1% 82% 20% D0% B7% D0% B0% D0% BF% D1 % 80% D0% BE% D1% 81% 20% D0% BD% D0% B0% 20% D1% 8D% D1% 82% D0% BE% D1% 82% 20% D0% B0% D0% B4% D1 % 80% D0% B5% D1% 81% 20% D1% 82% D0% B0% D0% BA% D0% B8% D0% BC% 20% D0% BE% D0% B1% D1% 80% D0% B0 % D0% B7% D0% BC% D0% BC% 2c% 20% D1% 87% D1% 82% D0% BE% 20% D0% BE% D0% BD% 20% D0% BD% D0% B8% D0 % Ba% D0% BE% D0% B3% D0% B4% D0% B0% 20% D0% BD% D0% B5% 20% D0% B7% D0% B0% D0% B2% D0% B5% D1% 80 % D1% 88% D0% B8% D1% 82% D1% 81% D1% 8F.

Answer 1, Authority 100%

It will not be possible to log in to the proxy. And try to fill the alert with authorization either will not work because not supported.

The only thing that can help is seleniumwire.

$: pip install selenium-wire
from seleniumwire import webdriver
Options = {
  'proxy': {
    'http': 'http: // user: [email protected]: 8888',
    'https': 'http: // user: [email protected]: 8888',
    'NO_PROXY': 'Localhost, 127.0.0.1'
  }
}
Driver = WebDriver.firefox (SeleniumWire_Options = Options)
Driver.get ("https://whoer.net")

p.s. Or wait a few days. I just finish the addition so that you can put a proxy with authorization and cookies. But this is not exactly)

p.p.s. https://github.com/alExSok-bit/selenium_Helper


Answer 2

Only one thing was helped to remove the User-Agent substitution or a random selection of Iery like this:

user_list = ["Mozilla / 4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident / 4.0)", " Mozilla / 4.0 (Compatible; MSIE 7.0; Windows NT 6.1; Trident / 7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MATP; MATP) "," Mozilla / 5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; TRIDENT / 6.0) "]
Ninja = Random.Choice (User_List)
Print (Ninja)
Option = WebDriver.firefoxoptions ()
option.set_preference ("Dom.WebDriver.Enabled", False)
option.set_preference ("general.useragent.Ordride", Ninja)
Driver = WebDriver.Firefox (options = option)
Driver.get ('https://browser-info.ru/')

You can also still be like this:

ninja = "'" + user-agent + "'"

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions