Skip to content

Instantly share code, notes, and snippets.

@kitisak
Last active March 9, 2020 02:03
Show Gist options
  • Select an option

  • Save kitisak/ae291b647bd53e27982ff375de1d2984 to your computer and use it in GitHub Desktop.

Select an option

Save kitisak/ae291b647bd53e27982ff375de1d2984 to your computer and use it in GitHub Desktop.
from selenium import webdriver
CHROME_PATH = "\path\to\chrome\driver"
# https://www.sslproxies.org/
PROXIES = [
"1.10.251.190:8080",
"13.94.36.9:1080",
"182.52.238.119:40456",
"52.230.6.90:8080",
"1.10.189.84:35138",
"79.234.181.21:8080"
]
chrome_options = webdriver.ChromeOptions()
for prox in PROXIES:
chrome_options.add_argument('--proxy-server=%s' % prox)
chrome = webdriver.Chrome(CHROME_PATH, options=chrome_options)
print("--- switched to: %s" % prox)
chrome.get("https://checkip.thaiware.com/")
try:
results = chrome.find_elements_by_css_selector('td.detail.right_col')
print("Result: " + results[0].text + " in " +results[1].text)
except:
print("Fail!!")
finally:
chrome.close()
pass
print("Complete")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment