diff options
author | Leonard Richardson <leonardr@segfault.org> | 2013-05-08 09:45:25 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2013-05-08 09:45:25 -0400 |
commit | f950cceae374a52adef286f84fa12a1cf6a08947 (patch) | |
tree | e69764a1015b6b1892e0af6b85a2521fa6ceb7cf | |
parent | 85fdee280651b14d0ceadbe889eb571118c126f2 (diff) |
Almost there.
-rw-r--r-- | bs4/element.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bs4/element.py b/bs4/element.py index 86e6c71..ae55fb6 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -608,7 +608,7 @@ class PageElement(object): else: return lambda el: el.has_attr(attribute) - def select(self, selector, recursive=True): + def select(self, selector): """Perform a CSS selection operation on the current element.""" tokens = selector.split() current_context = [self] @@ -638,7 +638,12 @@ class PageElement(object): tag_name, id = token.split('#', 1) if tag_name == "": tag_name = True - production_rule = lambda tag: [tag.find(tag_name, id=id)] + def find_by_id(tag): + found = tag.find(tag_name, id=id) + if found is None: + return [] + return [found] + production_rule = find_by_id checker = lambda x: True elif '.' in token: |