#NEWLINE# def _external_request( self , method , url , * args , **kwargs ) : #NEWLINE# #INDENT# '\n        Wrapper for requests.get with useragent automatically set.\n        And also all requests are reponses are cached.\n        ' #NEWLINE# self . last_url = url #NEWLINE# if ( ( url in self . responses . keys ( ) ) and ( method == 'get' ) ) : #NEWLINE# #INDENT# return self . responses [ url ] #NEWLINE# #UNINDENT# headers = kwargs . pop ( 'headers' , None ) #NEWLINE# custom = { #NEWLINE# #INDENT# 'User-Agent' : useragent , #NEWLINE# #UNINDENT# } #NEWLINE# if headers : #NEWLINE# #INDENT# headers . update ( custom ) #NEWLINE# kwargs [ 'headers' ] = headers #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kwargs [ 'headers' ] = custom #NEWLINE# #UNINDENT# if self . timeout : #NEWLINE# #INDENT# kwargs [ 'timeout' ] = self . timeout #NEWLINE# #UNINDENT# response = getattr ( requests , method ) ( url , * args , ** kwargs ) #NEWLINE# if self . verbose : #NEWLINE# #INDENT# print ( ( 'Got Response: %s' % url ) ) #NEWLINE# #UNINDENT# if ( response . status_code == 503 ) : #NEWLINE# #INDENT# raise SkipThisService ( '503 - Temporarily out of service.' ) #NEWLINE# #UNINDENT# if ( method == 'get' ) : #NEWLINE# #INDENT# self . responses [ url ] = response #NEWLINE# #UNINDENT# self . last_raw_response = response #NEWLINE# return response