10
10
from scrapy .utils .decorator import deprecated
11
11
from scrapy .http import TextResponse
12
12
from .lxmldocument import LxmlDocument
13
- from .list import XPathSelectorList
13
+ from .list import SelectorList
14
14
15
15
16
- __all__ = ['HtmlXPathSelector' , 'XmlXPathSelector' , 'XPathSelector' , \
17
- 'XPathSelectorList' ]
16
+ __all__ = ['HtmlXPathSelector' , 'XmlXPathSelector' , 'XPathSelector' ]
18
17
19
18
20
19
class XPathSelector (object_ref ):
@@ -25,8 +24,8 @@ class XPathSelector(object_ref):
25
24
26
25
def __init__ (self , response = None , text = None , namespaces = None , _root = None , _expr = None ):
27
26
if text is not None :
28
- response = TextResponse (url = 'about:blank' , \
29
- body = unicode_to_str (text , 'utf-8' ), encoding = 'utf-8' )
27
+ response = TextResponse (url = 'about:blank' , encoding = 'utf-8' ,
28
+ body = unicode_to_str (text , 'utf-8' ))
30
29
if response is not None :
31
30
_root = LxmlDocument (response , self ._parser )
32
31
@@ -39,7 +38,7 @@ def select(self, xpath):
39
38
try :
40
39
xpathev = self ._root .xpath
41
40
except AttributeError :
42
- return XPathSelectorList ([])
41
+ return SelectorList ([])
43
42
44
43
try :
45
44
result = xpathev (xpath , namespaces = self .namespaces )
@@ -51,7 +50,7 @@ def select(self, xpath):
51
50
52
51
result = [self .__class__ (_root = x , _expr = xpath , namespaces = self .namespaces )
53
52
for x in result ]
54
- return XPathSelectorList (result )
53
+ return SelectorList (result )
55
54
56
55
def re (self , regex ):
57
56
return extract_regex (regex , self .extract ())
@@ -84,10 +83,8 @@ def __nonzero__(self):
84
83
def __str__ (self ):
85
84
data = repr (self .extract ()[:40 ])
86
85
return "<%s xpath=%r data=%s>" % (type (self ).__name__ , self ._expr , data )
87
-
88
86
__repr__ = __str__
89
87
90
-
91
88
@deprecated (use_instead = 'XPathSelector.extract' )
92
89
def extract_unquoted (self ):
93
90
return self .extract ()
0 commit comments