<s> import logging <EOL> import requests <EOL> from cachecontrol . adapter import CacheControlAdapter <EOL> from cachecontrol . cache import DictCache <EOL> from cachecontrol . controller import logger <EOL> from argparse import ArgumentParser <EOL> def setup_logging ( ) : <EOL> logger . setLevel ( logging . DEBUG ) <EOL> handler = logging . StreamHandler ( ) <EOL> logger . addHandler ( handler ) <EOL> def get_session ( ) : <EOL> adapter = CacheControlAdapter ( <EOL> DictCache ( ) , <EOL> cache_etags = True , <EOL> serializer = None , <EOL> heuristic = None , <EOL> ) <EOL> sess = requests . Session ( ) <EOL> sess . mount ( '<STR_LIT>' , adapter ) <EOL> sess . mount ( '<STR_LIT>' , adapter ) <EOL> sess . cache_controller = adapter . controller <EOL> return sess <EOL> def get_args ( ) : <EOL> parser = ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT:url>' , help = '<STR_LIT>' ) <EOL> return parser . parse_args ( ) <EOL> def main ( args = None ) : <EOL> args = get_args ( ) <EOL> sess = get_session ( ) <EOL> resp = sess . get ( args . url ) <EOL> setup_logging ( ) <EOL> sess . cache_controller . cache_response ( resp . request , resp . raw ) <EOL> if sess . cache_controller . cached_request ( resp . request ) : <EOL> print ( '<STR_LIT>' ) <EOL> else : <EOL> print ( '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
