0

I'm trying to get cookie values by undetected_chromedriver.v2. Here is my code:

import undetected_chromedriver.v2 as uc
driver = uc.Chrome()
with driver:
 driver.get('https://thesite.com')
 driver.implicitly_wait(10) #waits until page loads (but it works strange)
 print(driver.get_cookies()) 

If I use time.sleep() instead if implicitly wait, the page loads only cloudflare page and endlessly reloads.

Browser opens. Then the site loads. And i see this:

Click.

But my code doesn't wait for completely loading and outputs:

[{'domain': 'thesite.com', 'expiry': 1621067731, 'httpOnly': False, 'name': 'cf_chl_prog', 'path': '/', 'secure': False, 'value': 'e'}]

Then the site finally loads and only now I'd like to get cookies.

What can I do?

P.S.: sorry for my bad english, i hope you understand me =)

Samsul Islam
  • 2,581
  • 2
  • 17
  • 23

1 Answers1

0
driver = uc.Chrome()
with driver:
    driver.get('https://thesite.com')
time.sleep(10)
with driver:
    cookies = driver.get_cookies()
print(cookies) 
Dharman
  • 30,962
  • 25
  • 85
  • 135