Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.74 KB | None | 0 0
  1. ##########################--BEFORE INSTALL--###################################################
  2.  
  3. # wget https://github.com/aghorler/WebRTC-Leak-Prevent/archive/master.zip #webrtc block extention
  4. # unzip master.zip
  5. # cd WebRTC-Leak-Prevent-master/
  6. # zip -r webrtc_ext.zip *
  7. # mv webrtc.zip ..
  8. # cd ..
  9. # rm -rf WebRTC-Leak-Prevent
  10. # rm master.zip
  11.  
  12. ###############################################################################################
  13.  
  14. from selenium import webdriver
  15. from selenium.webdriver.common.keys import Keys
  16. from selenium.webdriver.chrome.options import Options
  17. import os, time
  18.  
  19.  
  20. #
  21. #PROXY = "localhost:1050"
  22. #desired_capabilities = {
  23. #    "browserName": "chrome",
  24. #    "version": "68.0",
  25. #    "enableVNC": True,
  26. #    "sessionTimeout": "40m"
  27. #
  28. #}
  29. #desired_capabilities['proxy'] = {
  30. #    "httpProxy": PROXY,
  31. #    "ftpProxy": PROXY,
  32. #    "sslProxy": PROXY,
  33. #    "noProxy": None,
  34. #    "proxyType": "Manual",
  35. #    "class": "org.openqa.selenium.Proxy",
  36. #    "autodetect": False,
  37. #    "socksUsername": "LOGin",
  38. #    "sockPassword": "PAss"
  39. #
  40. #
  41. #}
  42. #
  43. #
  44.  
  45.  
  46. os.environ['HK']='Asia/Hong_Kong' # Change TIME ZONE
  47. time.tzset()
  48. ext_file = "webrtc.zip"
  49.  
  50. mobile_emulation = {
  51.   "deviceMetrics": {"width": 1920, "height": 1080, "pixelRatio": 3.0},
  52.    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36" }
  53. #mobile_emulation = {
  54. #    "deviceMetrics": {"width": 375, "height": 667, "pixelRatio": 3.0},
  55. #    "userAgent": "Mozilla/5.0 (iPhone 5; CPU iPhone OS 11_1_2 like Mac OS X ) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0 Mobile/15B202 Safari/604.1"}
  56. #mobile_emulation = {
  57. #    "deviceMetrics": {"width": 1280, "height": 768, "pixelRatio": 3.0},
  58. #    "userAgent": "Mozilla/5.0 (Windows; U; WinNT4.0; ru-ru; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1"}
  59. #mobile_emulation = {
  60. #    "deviceMetrics": {"width": 1680, "height": 845, "pixelRatio": 3.0},
  61. #    "userAgent": "Mozilla/5.0 (Windows 7; ru-ru; ) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/63"}
  62. device_choice = mobile_emulation
  63. print(device_choice)
  64. chrome_options = Options()
  65. chrome_options.add_extension(ext_file)
  66.  
  67.  
  68. chrome_options.add_experimental_option("mobileEmulation", device_choice)
  69. rand_proxy = "188.235.148.209:30554"
  70. print(rand_proxy)
  71. PROXY = rand_proxy  # IP:PORT or HOST:PORT
  72. chrome_options.add_argument('--proxy-server=%s' % PROXY)
  73. chrome_options.add_argument('--lang= en')
  74. chrome_options.add_argument("--start-maximized")
  75. chrome_options.add_argument("--window-position=1367,0")
  76.  
  77.  
  78. #driver = webdriver.Remote("http://localhost:4444/wd/hub", desired_capabilities) #if use selenoid
  79. driver = webdriver.Chrome(chrome_options=chrome_options) # CHROME
  80. driver.get("https://whoer.net")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement