Here are the examples of the python api scrapy.selector.XPathSelectorList taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
0
Example 1
def select(self, xpath):
"""Return elements using the webdriver `find_elements_by_xpath` method.
Some XPath features are not supported by the webdriver implementation.
Namely, selecting text content or attributes:
- /some/element/text()
- /some/element/@attribute
This function offers workarounds for both, so it should be safe to use
them as you would with HtmlXPathSelector for simple content extraction.
"""
xpathev = self.element if self.element else self.webdriver
ending = _UNSUPPORTED_XPATH_ENDING.match(xpath)
atsign = parens = None
if ending:
match, atsign, name, parens = ending.groups()
if atsign:
xpath = xpath[:-len(name) - 2]
elif parens and name == 'text':
xpath = xpath[:-len(name) - 3]
result = self._make_result(xpathev.find_elements_by_xpath(xpath))
if atsign:
result = (_NodeAttribute(r.element, name) for r in result)
elif parens and result and name == 'text':
result = (_TextNode(self.webdriver, r.element) for r in result)
return XPathSelectorList(result)
0
Example 2
Project: scrapy-webdriver Source File: selector.py
def select_script(self, script, *args):
"""Return elements using JavaScript snippet execution."""
result = self.webdriver.execute_script(script, *args)
return XPathSelectorList(self._make_result(result))