diff options
Diffstat (limited to 'bs4/element.py')
-rw-r--r-- | bs4/element.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bs4/element.py b/bs4/element.py index 474364b..5e15252 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -974,6 +974,8 @@ class SoupStrainer(object): found = markup else: found = markup_name + if found and self.text and self.text != found.string: + found = None return found searchTag = search_tag @@ -991,12 +993,12 @@ class SoupStrainer(object): # If it's a Tag, make sure its name or attributes match. # Don't bother with Tags if we're searching for text. elif isinstance(markup, Tag): - if not self.text: + if not self.text or self.name or self.attrs: found = self.search_tag(markup) # If it's text, make sure the text matches. elif isinstance(markup, NavigableString) or \ isinstance(markup, basestring): - if self._matches(markup, self.text): + if not self.name and not self.attrs and self._matches(markup, self.text): found = markup else: raise Exception( |