noodles пре 1 година
родитељ
комит
d9044ccd5f
2 измењених фајлова са 22 додато и 7 уклоњено
  1. 1 1
      person_interest.py
  2. 21 6
      utility.py

+ 1 - 1
person_interest.py

@@ -138,7 +138,7 @@ def main():
         print('restart docker p{}'.format(args.port))
         os.system('sudo docker container restart p'+str(args.port))
         time.sleep(8)
-        driver = brower_start(args.port)
+        driver = brower_start(args.port, 8787, False)
     url = 'https://www.linkedin.com/login'
     driver.get(url)
 

+ 21 - 6
utility.py

@@ -7,13 +7,28 @@ from selenium.webdriver.common.keys import Keys
 import time
 
 
-def brower_start(port):
+def brower_start(port, proxyport, chrome_window):
+    print(proxyport)
     options = webdriver.ChromeOptions()
-    browser = webdriver.Remote(
-        command_executor='http://127.0.0.1:'+str(port)+'/wd/hub',
-        desired_capabilities=options.to_capabilities()
-    )
-    return browser
+    if chrome_window:
+        browser = webdriver.Chrome(
+            desired_capabilities=options.to_capabilities()
+        )
+    else:
+        chrome_options = webdriver.ChromeOptions()
+        chrome_options.add_argument('--proxy-server=host.docker.internal:'+str(proxyport))  # Specify your Kubernetes service-name here
+        chrome_options.add_argument('--ignore-certificate-errors')
+        chrome_options.add_argument("--no-sandbox")
+        chrome_options.add_argument("--disable-dev-shm-usage")
+        browser = webdriver.Remote(
+            command_executor='http://127.0.0.1:'+str(port)+'/wd/hub',
+            desired_capabilities=chrome_options.to_capabilities(),
+            seleniumwire_options={'addr':'0.0.0.0','port':proxyport,'auto_config': False}
+
+            )
+#            seleniumwire_options = {'addr': '172.17.0.2','port':4444})
+        browser.set_window_size(1400,1000)
+    return browse
 
 
 def brower_start2(port):