Return default value if html node is not found
This commit is contained in:
parent
e289fc6b8f
commit
77f2213229
1 changed files with 2 additions and 0 deletions
|
|
@ -189,6 +189,8 @@ class Attr(Filter):
|
|||
try:
|
||||
return el[0].attrib[self.attr]
|
||||
except IndexError:
|
||||
if self.default is not _NO_DEFAULT:
|
||||
return self.default
|
||||
raise ValueError('Unable to find link %s' % self.selector)
|
||||
except KeyError:
|
||||
if self.default is not _NO_DEFAULT:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue