<s> try : <EOL> from urllib . parse import urljoin <EOL> except ImportError : <EOL> from urlparse import urljoin <EOL> import requests <EOL> from pyquery import PyQuery <EOL> from addic7ed_cli . error import Error <EOL> __all__ = [ '<STR_LIT>' ] <EOL> class Response ( object ) : <EOL> def __init__ ( self , response ) : <EOL> self . _response = response <EOL> self . _query = None <EOL> def __getattr__ ( self , name ) : <EOL> return getattr ( self . _response , name ) <EOL> def __call__ ( self , query ) : <EOL> if self . status_code >= <NUM_LIT> : <EOL> raise Error ( "<STR_LIT>" <EOL> . format ( self . url , self . status_code ) ) <EOL> if not self . _query : <EOL> self . _query = PyQuery ( self . content ) <EOL> return self . _query ( query ) <EOL> class Session ( requests . Session ) : <EOL> last_url = '<STR_LIT>' <EOL> def request ( self , method , url , * args , ** kwargs ) : <EOL> url = urljoin ( self . last_url , url ) <EOL> self . headers = { <EOL> '<STR_LIT>' : self . last_url , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = super ( Session , self ) . request ( method , url , * args , ** kwargs ) <EOL> self . last_url = response . url <EOL> return Response ( response ) <EOL> session = Session ( ) </s>
