Skip to content

Commit 960f885

Browse files
author
Jan Weiß
committed
Continue early in remove_unlikely_candidates() in case there is neither a class nor an id attribute.
1 parent 6b3961c commit 960f885

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

readability/readability.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ def debug(self, *a):
280280
def remove_unlikely_candidates(self):
281281
for elem in self.html.iter():
282282
s = "%s %s" % (elem.get('class', ''), elem.get('id', ''))
283+
if len(s) < 2:
284+
continue
283285
#self.debug(s)
284286
if REGEXES['unlikelyCandidatesRe'].search(s) and (not REGEXES['okMaybeItsACandidateRe'].search(s)) and elem.tag != 'body':
285287
self.debug("Removing unlikely candidate - %s" % describe(elem))

0 commit comments

Comments
 (0)