diff --git a/docs/topics/request-response.rst b/docs/topics/request-response.rst index a0d9fc03e..7af180bdf 100644 --- a/docs/topics/request-response.rst +++ b/docs/topics/request-response.rst @@ -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: diff --git a/scrapy/http/response/text.py b/scrapy/http/response/text.py index 8b12578d3..6e3f8a926 100644 --- a/scrapy/http/response/text.py +++ b/scrapy/http/response/text.py @@ -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 + `_ with + a different base URL. + """ if self._cached_base_url is None: self._cached_base_url = get_base_url( self.text[:4096],