(self, session)
Retrieve CSRF token from the server and append to HTTP headers.

        Args:
            session: Instance of requests.Session.
Retrieve CSRF token from the server and append to HTTP headers.
Retrieve CSRF token from the server and append to HTTP headers .
def _set_csrf_token(self, session):
        """Retrieve CSRF token from the server and append to HTTP headers.

        Args:
            session: Instance of requests.Session.
        """
        # Scrape the CSRF token from the response
        response = session.get(self._host_uri)
        soup = bs4.BeautifulSoup(response.text, features='html.parser')

        tag = soup.find(id='csrf_token')
        csrf_token = None
        if tag:
            csrf_token = tag.get('value')
        else:
            tag = soup.find('meta', attrs={'name': 'csrf-token'})
            if tag:
                csrf_token = tag.attrs.get('content')

        if not csrf_token:
            return

        session.headers.update({
            'x-csrftoken': csrf_token,
            'referer': self._host_uri
        })
def _set_csrf_token ( self , session ) : # Scrape the CSRF token from the response response = session . get ( self . _host_uri ) soup = bs4 . BeautifulSoup ( response . text , features = 'html.parser' ) tag = soup . find ( id = 'csrf_token' ) csrf_token = None if tag : csrf_token = tag . get ( 'value' ) else : tag = soup . find ( 'meta' , attrs = { 'name' : 'csrf-token' } ) if tag : csrf_token = tag . attrs . get ( 'content' ) if not csrf_token : return session . headers . update ( { 'x-csrftoken' : csrf_token , 'referer' : self . _host_uri } )