#NEWLINE# def _extract_links( self , response_text , response_url , response_encoding , base_url = None ) : #NEWLINE# #INDENT# if ( base_url is None ) : #NEWLINE# #INDENT# base_url = ( urljoin ( response_url , self . base_url ) if self . base_url else response_url ) #NEWLINE# #UNINDENT# clean_url = ( lambda u : urljoin ( base_url , replace_entities ( clean_link ( u . decode ( response_encoding ) ) ) ) ) #NEWLINE# clean_text = ( lambda t : replace_escape_chars ( remove_tags ( t . decode ( response_encoding ) ) ) . strip ( ) ) #NEWLINE# links_text = linkre . findall ( text ) #NEWLINE# return [ Link ( clean_url ( url ) . encode ( response_encoding ) , clean_text ( text ) ) for ( url , _ , text ) in links_text ]