79199910

Date: 2024-11-18 12:34:03
Score: 1
Natty:
Report link

Complementing @Michael Mintz 's approach,here's a possible fix I tried and worked: Automatically set the version_main from the Error log Using a regular Expression as shown in the snippet below:

import re
import undetected_chromedriver as uc
def initialize_session():
        try: 
            sess = uc.Chrome()
        except Exception as e: 
            main_version_string = re.search(r"Current browser version is (\d+\.\d+\.\d+)", str(e)).group(1)
            main_version = int(main_version_string.split(".")[0])
            sess = uc.Chrome(version_main=main_version)
        return sess
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Michael
  • Low reputation (1):
Posted by: wreak havocc