mirror of https://github.com/scrapy/scrapy.git
upgrade parsel and using promoted root attribute
This commit is contained in:
parent
67c98b185b
commit
2fe6d128f5
|
|
@ -7,4 +7,4 @@ queuelib
|
|||
six>=1.5.2
|
||||
PyDispatcher>=2.0.5
|
||||
service_identity
|
||||
parsel>=0.9.1
|
||||
parsel>=0.9.2
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class LxmlParserLinkExtractor(object):
|
|||
def _extract_links(self, selector, response_url, response_encoding, base_url):
|
||||
links = []
|
||||
# hacky way to get the underlying lxml parsed document
|
||||
for el, attr, attr_val in self._iter_links(selector._root):
|
||||
for el, attr, attr_val in self._iter_links(selector.root):
|
||||
# pseudo lxml.html.HtmlElement.make_links_absolute(base_url)
|
||||
attr_val = urljoin(base_url, attr_val)
|
||||
url = self.process_attr(attr_val)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ class Selector(ParselSelector, object_ref):
|
|||
super(Selector, self).__init__(text=text, type=st, root=root, **kwargs)
|
||||
|
||||
# Deprecated api
|
||||
@property
|
||||
def _root(self):
|
||||
warnings.warn("Attribute `_root` is deprecated, use `root` instead",
|
||||
ScrapyDeprecationWarning, stacklevel=2)
|
||||
return self.root
|
||||
|
||||
@deprecated(use_instead='.xpath()')
|
||||
def select(self, xpath):
|
||||
return self.xpath(xpath)
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -44,7 +44,7 @@ setup(
|
|||
'pyOpenSSL',
|
||||
'cssselect>=0.9',
|
||||
'six>=1.5.2',
|
||||
'parsel>=0.9.1',
|
||||
'parsel>=0.9.2',
|
||||
'PyDispatcher>=2.0.5',
|
||||
'service_identity',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class SelectorTestCase(unittest.TestCase):
|
|||
def test_deprecated_root_argument(self, warnings):
|
||||
root = etree.fromstring(u'<html/>')
|
||||
sel = self.sscls(_root=root)
|
||||
self.assertIs(root, sel._root)
|
||||
self.assertIs(root, sel.root)
|
||||
warnings.warn.assert_called_once_with(
|
||||
'Argument `_root` is deprecated, use `root` instead',
|
||||
mock.ANY, stacklevel=2)
|
||||
|
|
|
|||
Loading…
Reference in New Issue