0

I have very simple piece of code:

from selenium.webdriver.common import proxy as _px
myProxy = 'http://217.76.186.242:1080'

proxy = _px.Proxy({
    'proxyType': _px.ProxyType.MANUAL,
    'httpProxy': myProxy,
    'ftpProxy': myProxy,
    'sslProxy': myProxy,
    'noProxy': ''})

profile = webdriver.FirefoxProfile()
profile.set_preference("general.useragent.override", choice(user_agents))
driver = webdriver.Firefox(firefox_profile=profile, proxy=proxy)
dirver.get("http://www.google.ru")

but it doesn't work. it throws an exception:

Traceback (most recent call last):
  File "google_blog.py", line 30, in <module>
    'noProxy': ''})
  File "/home/********/.virtualenvs/helpers/local/lib/python2.7/site-packages/selenium/webdriver/common/proxy.py", line 66, in __init__
    self.proxy_type = ProxyType.load(raw['proxyType'])
  File "/home/********/.virtualenvs/helpers/local/lib/python2.7/site-packages/selenium/webdriver/common/proxy.py", line 39, in load
    raise Exception("No proxy type is found for %s" % (value))
  Exception: No proxy type is found for {'FF_VALUE': 1, 'STRING': 'MANUAL'}  

It seems like everything's fine. But no. Any hints?

1 Answer 1

2

I see the problem, temporary workaround is to use

'proxyType': 'MANUAL' 

instead of

'proxyType': ProxyType.MANUAL
Sign up to request clarification or add additional context in comments.

2 Comments

That work! but why? I've tried to do it like in the docs first, but it didn't work...now everything is ok. Thanks
@oleg.foreigner seems bug with newer versions. It works for older versions. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.