REST API provides programmatic access to GoLogin App. Create a new browser profile, get a list of all browser profiles, add a browser profile and running
I try click all links web. But when i use profile Gologin, it click about 13 - 24 links then Orbita auto quit.
I try use Chrome (don't use profile Gologin) then normal.
What's problem? where's error?
Please help me!
Example here:
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from gologin import GoLogin
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
gl = GoLogin({
"token": "my_token",
"profile_id": "my_profile_id"
})
debugger_address = gl.start()
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", debugger_address)
s = Service('chromedriver115.exe')
driver = webdriver.Chrome(service=s, options=chrome_options)
driver.maximize_window()
driver.get('https://dantri.com.vn')
action = ActionChains(driver)
time.sleep(2)
eles = driver.find_elements(By.TAG_NAME,'a')
print(len(eles))
count = 0
for ele in eles:
lenHandle = len(driver.window_handles)
url = driver.current_url
try: action.key_down(Keys.CONTROL).click(ele).key_up(Keys.CONTROL).perform()
except: continue
if len(driver.window_handles) == lenHandle:
if driver.current_url != url: driver.back()
continue
driver.switch_to.window(driver.window_handles[-1])
print(f'count: {count}, index: {eles.index(ele)}')
count += 1
time.sleep(10)
driver.close()
driver.switch_to.window(driver.window_handles[0])
print('finish')
driver.quit()
time.sleep(3)
gl.stop()
Error:
722
count: 0, index: 0
count: 1, index: 1
count: 2, index: 2
count: 3, index: 3
count: 4, index: 4
count: 5, index: 5
count: 6, index: 6
count: 7, index: 7
count: 8, index: 8
count: 9, index: 9
count: 10, index: 10
count: 11, index: 11
count: 12, index: 12
count: 13, index: 13
count: 14, index: 14
count: 15, index: 15
count: 16, index: 16
count: 17, index: 17
count: 18, index: 18
count: 19, index: 19
count: 20, index: 20
Traceback (most recent call last):
File "d:\Code\pygologin-main\gologin\gologin-selenium.py", line 29, in
lenHandle = len(driver.window_handles)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lazy Cat\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 491, in window_handles
return self.execute(Command.W3C_GET_WINDOW_HANDLES)["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lazy Cat\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 344, in execute
self.error_handler.check_response(response)
File "C:\Users\Lazy Cat\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: disconnected: not connected to DevTools
(failed to check if window was closed: disconnected: not connected to DevTools)
(Session info: chrome=115.0.5790.82)
Stacktrace:
Backtrace:
GetHandleVerifier [0x007B1C53+49427]
(No symbol) [0x00745F41]
(No symbol) [0x0064C64D]
(No symbol) [0x0063CCA9]
(No symbol) [0x0063D1FA]
(No symbol) [0x0063D198]
(No symbol) [0x0063235D]
(No symbol) [0x00632BFD]
(No symbol) [0x0069D347]
(No symbol) [0x006949E3]
(No symbol) [0x00671127]
(No symbol) [0x006722AD]
GetHandleVerifier [0x00A07149+2496009]
GetHandleVerifier [0x00A4D572+2783794]
GetHandleVerifier [0x00A47491+2758993]
GetHandleVerifier [0x008311D0+571024]
(No symbol) [0x0074F96A]
(No symbol) [0x0074BD88]
(No symbol) [0x0074BE6B]
(No symbol) [0x0073EA97]
BaseThreadInitThunk [0x76947D59+25]
RtlInitializeExceptionChain [0x7784B79B+107]
RtlClearBits [0x7784B71F+191]
I try click all links web. But when i use profile Gologin, it click about 13 - 24 links then Orbita auto quit. I try use Chrome (don't use profile Gologin) then normal.
What's problem? where's error?
Please help me!
Example here:
Error: