class documentation

class Selector(_ParselSelector, object_ref):

View In Hierarchy

An instance of Selector is a wrapper over response to select certain parts of its content.

response is an ~scrapy.http.HtmlResponse or an ~scrapy.http.XmlResponse object that will be used for selecting and extracting data.

text is a unicode string or utf-8 encoded text for cases when a response isn't available. Using text and response together is undefined behavior.

type defines the selector type, it can be "html", "xml" or None (default).

If type is None, the selector automatically chooses the best type based on response type (see below), or defaults to "html" in case it is used together with text.

If type is None and a response is passed, the selector type is inferred from the response type as follows:

  • "html" for ~scrapy.http.HtmlResponse type
  • "xml" for ~scrapy.http.XmlResponse type
  • "html" for anything else

Otherwise, if type is set, the selector type will be forced and no detection will occur.

Method __init__ Undocumented
Class Variable __slots__ Undocumented
Instance Variable response Undocumented

Inherited from object_ref:

Method __new__ Undocumented
def __init__(self, response=None, text=None, type=None, root=None, **kwargs):

Undocumented

__slots__: list[str] =
response =

Undocumented