add **kwargs to manage extra args in xpath and cssselect
This commit is contained in:
parent
5ea0307b6a
commit
11efe2d85d
1 changed files with 3 additions and 3 deletions
|
|
@ -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:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue