#NEWLINE# def _extract_biblio( self , page , id = None ) : #NEWLINE# #INDENT# biblio_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( not page ) : #NEWLINE# #INDENT# return biblio_dict #NEWLINE# #UNINDENT# unicode_page = to_unicode_or_bust ( page ) #NEWLINE# try : #NEWLINE# #INDENT# parsed_html = lxml . html . document_fromstring ( unicode_page ) #NEWLINE# try : #NEWLINE# #INDENT# response = parsed_html . find ( './/title' ) . text #NEWLINE# if ( response and response . strip ( ) ) : #NEWLINE# #INDENT# biblio_dict [ 'title' ] = response . strip ( ) #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# response = parsed_html . find ( './/h1' ) . text #NEWLINE# if ( response and response . strip ( ) ) : #NEWLINE# #INDENT# biblio_dict [ 'h1' ] = response . strip ( ) #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# except ( ValueError , lxml . etree . ParserError ) : #NEWLINE# #INDENT# logger . warning ( ( "%20s couldn't parse %s so giving up on webpage biblio" % ( self . provider_name , id ) ) ) #NEWLINE# try : #NEWLINE# #INDENT# response = re . search ( '<title>(.+?)</title>' , unicode_page ) . group ( 1 ) #NEWLINE# response . replace ( '\n' , '' ) #NEWLINE# response . replace ( '\r' , '' ) #NEWLINE# if unicode_page : #NEWLINE# #INDENT# biblio_dict [ 'title' ] = response . strip ( ) #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# return biblio_dict