diff --git a/requirements.txt b/requirements.txt index ffa5b3025..f8a0f7ad3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ queuelib six>=1.5.2 PyDispatcher>=2.0.5 service_identity -parsel>=0.9.1 +parsel>=0.9.2 diff --git a/scrapy/linkextractors/lxmlhtml.py b/scrapy/linkextractors/lxmlhtml.py index 7c41a88ff..606a45212 100644 --- a/scrapy/linkextractors/lxmlhtml.py +++ b/scrapy/linkextractors/lxmlhtml.py @@ -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) diff --git a/scrapy/selector/unified.py b/scrapy/selector/unified.py index 3c75a92d2..e229b10b8 100644 --- a/scrapy/selector/unified.py +++ b/scrapy/selector/unified.py @@ -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) diff --git a/setup.py b/setup.py index 6fe303f15..2d2d8660f 100644 --- a/setup.py +++ b/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', ], diff --git a/tests/test_selector.py b/tests/test_selector.py index 8dc194e19..d9660c674 100644 --- a/tests/test_selector.py +++ b/tests/test_selector.py @@ -43,7 +43,7 @@ class SelectorTestCase(unittest.TestCase): def test_deprecated_root_argument(self, warnings): root = etree.fromstring(u'') 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)