Advertisement
Guest User

Untitled

a guest
Apr 4th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. import json
  2. import random
  3.  
  4. from selenium.common.exceptions import TimeoutException
  5.  
  6. from selenium import webdriver
  7. from selenium.webdriver.support.ui import WebDriverWait
  8. from selenium.webdriver.firefox.options import Options
  9. from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
  10. from selenium.webdriver.common.proxy import Proxy, ProxyType
  11. import platform
  12. import requests
  13. import urllib.request
  14. import os
  15.  
  16.  
  17. def chrome_binary_path():
  18. os_sys = platform.system()
  19. if os_sys == "Windows":
  20. return r'{}\driver\chromedriver.exe'.format(os.getcwd())
  21. elif os_sys == 'Darwin':
  22. return '/usr/local/bin/chromedriver'
  23.  
  24.  
  25. username = 'lum-customer-hl_185d159c-zone-static-route_err-pass_dyn'
  26. password = 'io2z95j7jj2w'
  27. port = 22225
  28. session_id = random.random()
  29. super_proxy_url = ('http://%s-session-%s:%s@zproxy.lum-superproxy.io:%d' %
  30. (username, session_id, password, port))
  31. proxy_handler = urllib.request.ProxyHandler({
  32. 'http': super_proxy_url,
  33. 'https': super_proxy_url,
  34. })
  35. opener = urllib.request.build_opener(proxy_handler)
  36. proxy_details = opener.open('http://lumtest.com/myip.json').read()
  37. data = json.loads(proxy_details)
  38.  
  39.  
  40. PROXY = data['ip']+":"+"22225"
  41. options = webdriver.ChromeOptions()
  42. options.add_argument("--start-maximized")
  43. options.add_argument('--proxy-server=%s' % PROXY)
  44.  
  45.  
  46. driver = webdriver.Chrome(
  47. executable_path=chrome_binary_path(), options=options)
  48. driver.set_page_load_timeout(120)
  49.  
  50. driver.get("https://whatismyipaddress.com/")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement