File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ def __init__(self):
7474 # holds links found in the main article
7575 self .links = []
7676
77+ # hold author names
78+ self .authors = []
79+
7780 # stores the final URL that we're going to try
7881 # and fetch content against, this would be expanded if any
7982 self .final_url = u""
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ def crawl(self, crawl_candidate):
105105 self .article .canonical_link = self .extractor .get_canonical_link ()
106106 self .article .domain = self .extractor .get_domain ()
107107 self .article .tags = self .extractor .extract_tags ()
108+ self .article .authors = self .extractor .extract_authors ()
108109
109110 # opengraph
110111 self .article .opengraph = self .extractor .extract_opengraph ()
Original file line number Diff line number Diff line change @@ -259,6 +259,25 @@ def extract_links(self):
259259 links .append (attr )
260260 return links
261261
262+ def extract_authors (self ):
263+ authors = []
264+ author_nodes = self .parser .getElementsByTag (
265+ self .article .doc ,
266+ attr = 'itemprop' ,
267+ value = 'author' )
268+
269+ for author in author_nodes :
270+ name_nodes = self .parser .getElementsByTag (
271+ author ,
272+ attr = 'itemprop' ,
273+ value = 'name' )
274+
275+ if len (name_nodes ) > 0 :
276+ name = self .parser .getText (name_nodes [0 ])
277+ authors .append (name )
278+
279+ return list (set (authors ))
280+
262281 def extract_tags (self ):
263282 node = self .article .doc
264283
You can’t perform that action at this time.
0 commit comments