Andrew Foxis
Andrew Foxis

Reputation: 81

Python+Selenium+PhantomJS. Waiting for proxy

The code is given proxy to using it through the PhantomJS to load the page. But it happens that proxies are either too slow or does not work. Tell me please how to make sure that the page is trying to open, but for example on the expiration of 20-30 seconds was issued a message that "The proxy does not work.

from selenium import webdriver
browser=webdriver.PhantomJS()
service_args = [
    '--proxy=10.10.20.20:3128',
    '--proxy-type=http',
    ]
browser = webdriver.PhantomJS(service_args=service_args)
browser.get('http://check-host.net/ip')
browser.quit()

Maybe "Try....Catch..." Help me plese. Thank you advance!

Upvotes: 1

Views: 227

Answers (1)

user1069596
user1069596

Reputation:

try: <browser.get()> sleep(5) except Exception as e: print e

Upvotes: 1

Related Questions