diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-15 14:07:04 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-15 14:07:04 -0500 |
commit | be0c08585f54ec709740ff4352006bf3e605b8f2 (patch) | |
tree | 342c8a482bef4490a8f0fbb528611888bcf76721 /bs4/element.py | |
parent | 0f6d3cfbef6fc0b90f0e9fbe58408e00c2383070 (diff) |
Better defined behavior when the user wants to search for a combination of text and tag-specific arguments. [bug=695312]
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( |