lookyloo/lookyloo.py
def _ensure_meta(self, capture_dir: Path, tree: CrawledTree) -> None:
        '''Make sure the meta file is present, it contains information about the User Agent used for the capture.'''
        metafile = capture_dir / 'meta'
        if metafile.exists():
            return
        ua = UserAgent(tree.root_hartree.user_agent)
        to_dump = {}
        if ua.platform:
            to_dump['os'] = ua.platform
        if ua.browser:
            if ua.version:
                to_dump['browser'] = f'{ua.browser} {ua.version}'
            else:
                to_dump['browser'] = ua.browser
        if ua.language:
            to_dump['language'] = ua.language

        if not to_dump:
            # UA not recognized
            self.logger.info(f'Unable to recognize the User agent: {ua}')
        to_dump['user_agent'] = ua.string
        with metafile.open('w') as f:
            json.dump(to_dump, f)
Make sure the meta file is present, it contains information about the User Agent used for the capture.
Make sure the meta file is present, it contains information about the User Agent used for the capture.
Make sure the meta file is present it contains information about the User Agent used for the capture .
def _ensure_meta(self, capture_dir: Path, tree: CrawledTree) -> None:
        metafile = capture_dir / 'meta'
        if metafile.exists():
            return
        ua = UserAgent(tree.root_hartree.user_agent)
        to_dump = {}
        if ua.platform:
            to_dump['os'] = ua.platform
        if ua.browser:
            if ua.version:
                to_dump['browser'] = f'{ua.browser} {ua.version}'
            else:
                to_dump['browser'] = ua.browser
        if ua.language:
            to_dump['language'] = ua.language
        if not to_dump:
            self.logger.info(f'Unable to recognize the User agent: {ua}')
        to_dump['user_agent'] = ua.string
        with metafile.open('w') as f:
            json.dump(to_dump, f)
def _ensure_meta ( self , capture_dir : Path , tree : CrawledTree ) -> None : metafile = capture_dir / 'meta' if metafile . exists ( ) : return ua = UserAgent ( tree . root_hartree . user_agent ) to_dump = { } if ua . platform : to_dump [ 'os' ] = ua . platform if ua . browser : if ua . version : to_dump [ 'browser' ] = f'{ua.browser} {ua.version}' else : to_dump [ 'browser' ] = ua . browser if ua . language : to_dump [ 'language' ] = ua . language if not to_dump : self . logger . info ( f'Unable to recognize the User agent: {ua}' ) to_dump [ 'user_agent' ] = ua . string with metafile . open ( 'w' ) as f : json . dump ( to_dump , f )
Make sure the meta file is present, it contains information about the User Agent used for the capture.
Make sure the meta file is present it contains information about the User Agent used for the capture .
'''Make sure the meta file is present, it contains information about the User Agent used for the capture.''' # UA not recognized
self
capture_dir
Path
tree
CrawledTree