class documentation

class TextResponse(Response):

Known subclasses: scrapy.http.response.html.HtmlResponse, scrapy.http.response.xml.XmlResponse

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method ​_auto​_detect​_fun Undocumented
Method ​_body​_declared​_encoding Undocumented
Method ​_body​_inferred​_encoding Undocumented
Method ​_declared​_encoding Undocumented
Method ​_headers​_encoding Undocumented
Method ​_set​_body Undocumented
Method ​_set​_url Undocumented
Method body​_as​_unicode Return body as unicode
Method css Shortcut method implemented only by responses whose content is text (subclasses of TextResponse).
Method follow Return a ~.Request instance to follow a link url. It accepts the same arguments as Request.__init__ method, but url can be not only an absolute URL, but also
Method follow​_all No summary
Method json
New in version 2.2.
Method replace Create a new Response with the same attributes except for those given new values.
Method urljoin Join this Response's url with a possible relative url to form an absolute interpretation of the latter.
Method xpath Shortcut method implemented only by responses whose content is text (subclasses of TextResponse).
Constant ​_DEFAULT​_ENCODING Undocumented
Instance Variable ​_body Undocumented
Instance Variable ​_cached​_benc Undocumented
Instance Variable ​_cached​_decoded​_json Undocumented
Instance Variable ​_cached​_selector Undocumented
Instance Variable ​_cached​_ubody Undocumented
Instance Variable ​_encoding Undocumented
Instance Variable ​_url Undocumented
Property encoding Undocumented
Property selector Undocumented
Property text Body as unicode

Inherited from Response:

Method __str__ Undocumented
Method ​_get​_body Undocumented
Method ​_get​_url Undocumented
Method copy Return a copy of this Response
Class Variable body Undocumented
Class Variable url Undocumented
Instance Variable certificate Undocumented
Instance Variable flags Undocumented
Instance Variable headers Undocumented
Instance Variable ip​_address Undocumented
Instance Variable protocol Undocumented
Instance Variable request Undocumented
Instance Variable status Undocumented
Property cb​_kwargs Undocumented
Property meta Undocumented

Inherited from object_ref (via Response):

Method __new__ Undocumented
Class Variable __slots__ Undocumented
def __init__(self, *args, **kwargs):
def _auto_detect_fun(self, text):

Undocumented

@memoizemethod_noargs
def _body_declared_encoding(self):

Undocumented

def _body_inferred_encoding(self):

Undocumented

def _declared_encoding(self):

Undocumented

@memoizemethod_noargs
def _headers_encoding(self):

Undocumented

def _set_body(self, body):
def _set_url(self, url):
def body_as_unicode(self):
Return body as unicode
def css(self, query):
Shortcut method implemented only by responses whose content is text (subclasses of TextResponse).
def follow(self, url, callback=None, method='GET', headers=None, body=None, cookies=None, meta=None, encoding=None, priority=0, dont_filter=False, errback=None, cb_kwargs=None, flags=None):

Return a ~.Request instance to follow a link url. It accepts the same arguments as Request.__init__ method, but url can be not only an absolute URL, but also

  • a relative URL
  • a ~scrapy.link.Link object, e.g. the result of :ref:`topics-link-extractors`
  • a ~scrapy.selector.Selector object for a <link> or <a> element, e.g. response.css('a.my_link')[0]
  • an attribute ~scrapy.selector.Selector (not SelectorList), e.g. response.css('a::attr(href)')[0] or response.xpath('//img/@src')[0]

See :ref:`response-follow-example` for usage examples.

def follow_all(self, urls=None, callback=None, method='GET', headers=None, body=None, cookies=None, meta=None, encoding=None, priority=0, dont_filter=False, errback=None, cb_kwargs=None, flags=None, css=None, xpath=None):

A generator that produces ~.Request instances to follow all links in urls. It accepts the same arguments as the ~.Request's __init__ method, except that each urls element does not need to be an absolute URL, it can be any of the following:

  • a relative URL
  • a ~scrapy.link.Link object, e.g. the result of :ref:`topics-link-extractors`
  • a ~scrapy.selector.Selector object for a <link> or <a> element, e.g. response.css('a.my_link')[0]
  • an attribute ~scrapy.selector.Selector (not SelectorList), e.g. response.css('a::attr(href)')[0] or response.xpath('//img/@src')[0]

In addition, css and xpath arguments are accepted to perform the link extraction within the follow_all method (only one of urls, css and xpath is accepted).

Note that when passing a SelectorList as argument for the urls parameter or using the css or xpath parameters, this method will not produce requests for selectors from which links cannot be obtained (for instance, anchor tags without an href attribute)

def json(self):
New in version 2.2.

Deserialize a JSON document to a Python object.

def replace(self, *args, **kwargs):
Create a new Response with the same attributes except for those given new values.
def urljoin(self, url):
Join this Response's url with a possible relative url to form an absolute interpretation of the latter.
def xpath(self, query, **kwargs):
Shortcut method implemented only by responses whose content is text (subclasses of TextResponse).
_DEFAULT_ENCODING: str =

Undocumented

Value
'ascii'
_body =

Undocumented

_cached_benc =

Undocumented

_cached_decoded_json =

Undocumented

_cached_selector =

Undocumented

_cached_ubody =

Undocumented

_encoding =

Undocumented

_url =

Undocumented

@property
encoding =

Undocumented

@property
selector =

Undocumented

@property
text =
Body as unicode