def copy_user_agent_from_driver ( self ) : selenium_user_agent = self . driver . execute_script ( "return navigator.userAgent;" ) self . headers . update ( { "user-agent" : selenium_user_agent } )
change user agent for my crawler python
Updates requests session user - agent with the driver s user agent
def copy_user_agent_from_driver(self):
        """ Updates requests' session user-agent with the driver's user agent

        This method will start the browser process if its not already running.
        """
        selenium_user_agent = self.driver.execute_script("return navigator.userAgent;")
        self.headers.update({"user-agent": selenium_user_agent})