add **kwargs to manage extra args in xpath and cssselect

This commit is contained in:
Bezleputh 2014-02-24 20:09:28 +01:00
commit 11efe2d85d

View file

@ -60,7 +60,7 @@ class LxmlParser(IParser):
return self.tocleanstring(doc) return self.tocleanstring(doc)
@classmethod @classmethod
def select(cls, element, selector, nb=None, method='cssselect'): def select(cls, element, selector, nb=None, method='cssselect', **kwargs):
""" """
Select one or many elements from an element, using lxml cssselect by default. Select one or many elements from an element, using lxml cssselect by default.
@ -78,9 +78,9 @@ class LxmlParser(IParser):
:rtype: Element :rtype: Element
""" """
if method == 'cssselect': if method == 'cssselect':
results = element.cssselect(selector) results = element.cssselect(selector, **kwargs)
elif method == 'xpath': elif method == 'xpath':
results = element.xpath(selector) results = element.xpath(selector, **kwargs)
else: else:
raise NotImplementedError('Only the cssselect and xpath methods are supported') raise NotImplementedError('Only the cssselect and xpath methods are supported')
if nb is None: if nb is None: