mirror of https://github.com/scrapy/scrapy.git
Document TextResponse.base_url
This commit is contained in:
parent
7bb5289ced
commit
9ee2ebea54
|
|
@ -1203,6 +1203,8 @@ TextResponse objects
|
|||
|
||||
.. autoattribute:: TextResponse.attributes
|
||||
|
||||
.. autoattribute:: TextResponse.base_url
|
||||
|
||||
:class:`TextResponse` objects support the following methods in addition to
|
||||
the standard :class:`Response` ones:
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,13 @@ class TextResponse(Response):
|
|||
|
||||
@property
|
||||
def base_url(self) -> str:
|
||||
"""Base URL"""
|
||||
"""Base URL for any relative URL in the response.
|
||||
|
||||
It defaults to the response :attr:`~scrapy.http.Response.url`, but HTML
|
||||
responses may include a `base element
|
||||
<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base>`_ with
|
||||
a different base URL.
|
||||
"""
|
||||
if self._cached_base_url is None:
|
||||
self._cached_base_url = get_base_url(
|
||||
self.text[:4096],
|
||||
|
|
|
|||
Loading…
Reference in New Issue