Also use css expressions for textSearch.
This commit is contained in:
parent
6a70bf4671
commit
303432fc68
1 changed files with 5 additions and 1 deletions
|
@ -451,9 +451,13 @@ class _ParserScraper(Scraper):
|
||||||
@classmethod
|
@classmethod
|
||||||
def fetchText(cls, url, data, textSearch, optional):
|
def fetchText(cls, url, data, textSearch, optional):
|
||||||
"""Search text entry for given text XPath in a HTML page."""
|
"""Search text entry for given text XPath in a HTML page."""
|
||||||
|
if cls.css:
|
||||||
|
searchFun = data.cssselect
|
||||||
|
else:
|
||||||
|
searchFun = data.xpath
|
||||||
if textSearch:
|
if textSearch:
|
||||||
text = ''
|
text = ''
|
||||||
for match in data.xpath(textSearch):
|
for match in searchFun(textSearch):
|
||||||
try:
|
try:
|
||||||
text += ' ' + match.text_content()
|
text += ' ' + match.text_content()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
Loading…
Reference in a new issue