@@ -131,7 +131,7 @@ def get_favicon(self, article):
131131 kwargs = {'tag' : 'link' , 'attr' : 'rel' , 'value' : 'icon' }
132132 meta = Parser .getElementsByTag (article .doc , ** kwargs )
133133 if meta :
134- favicon = meta [0 ]. attrib . get ( 'href' )
134+ favicon = Parser . getAttribute ( meta [0 ], 'href' )
135135 return favicon
136136 return ''
137137
@@ -169,7 +169,7 @@ def get_meta_content(self, doc, metaName):
169169 content = None
170170
171171 if meta is not None and len (meta ) > 0 :
172- content = meta [0 ]. attrib . get ( 'content' )
172+ content = Parser . getAttribute ( meta [0 ], 'content' )
173173
174174 if content :
175175 return content .strip ()
@@ -196,7 +196,7 @@ def get_canonical_link(self, article):
196196 kwargs = {'tag' : 'link' , 'attr' : 'rel' , 'value' : 'canonical' }
197197 meta = Parser .getElementsByTag (article .doc , ** kwargs )
198198 if meta is not None and len (meta ) > 0 :
199- href = meta [0 ]. attrib . get ( 'href' )
199+ href = Parser . getAttribute ( meta [0 ], 'href' )
200200 if href :
201201 href = href .strip ()
202202 o = urlparse (href )
@@ -277,10 +277,10 @@ def calculate_best_node(self, article):
277277 # parent node
278278 parent_node = Parser .getParent (node )
279279 self .update_score (parent_node , upscore )
280- self .update_node_count (node . getparent () , 1 )
280+ self .update_node_count (parent_node , 1 )
281281
282- if node . getparent () not in parent_nodes :
283- parent_nodes .append (node . getparent () )
282+ if parent_node not in parent_nodes :
283+ parent_nodes .append (parent_node )
284284
285285 # parentparent node
286286 parent_parent_node = Parser .getParent (parent_node )
@@ -414,24 +414,24 @@ def update_score(self, node, addToScore):
414414 we're passing in to the current
415415 """
416416 current_score = 0
417- score_string = node . attrib . get ( 'gravityScore' )
417+ score_string = Parser . getAttribute ( node , 'gravityScore' )
418418 if score_string :
419419 current_score = int (score_string )
420420
421421 new_score = current_score + addToScore
422- node . set ( "gravityScore" , str (new_score ))
422+ Parser . setAttribute ( node , "gravityScore" , str (new_score ))
423423
424424 def update_node_count (self , node , add_to_count ):
425425 """\
426426 stores how many decent nodes are under a parent node
427427 """
428428 current_score = 0
429- count_string = node . attrib . get ( 'gravityNodes' )
429+ count_string = Parser . getAttribute ( node , 'gravityNodes' )
430430 if count_string :
431431 current_score = int (count_string )
432432
433433 new_score = current_score + add_to_count
434- node . set ( "gravityNodes" , str (new_score ))
434+ Parser . setAttribute ( node , "gravityNodes" , str (new_score ))
435435
436436 def is_highlink_density (self , e ):
437437 """\
@@ -468,7 +468,7 @@ def get_score(self, node):
468468 return self .get_node_gravity_score (node ) or 0
469469
470470 def get_node_gravity_score (self , node ):
471- grvScoreString = node . attrib . get ( 'gravityScore' )
471+ grvScoreString = Parser . getAttribute ( node , 'gravityScore' )
472472 if not grvScoreString :
473473 return None
474474 return int (grvScoreString )
0 commit comments