MCPcopy
hub / github.com/scrapy/scrapy / follow

Method follow

scrapy/http/response/__init__.py:220–268  ·  view source on GitHub ↗

Return a :class:`~.Request` instance to follow a link ``url``. It accepts the same arguments as ``Request.__init__()`` method, but ``url`` can be a relative URL or a :class:`~scrapy.link.Link` object, not only an absolute URL. :class:`~.TextResponse` provide

(
        self,
        url: str | Link,
        callback: CallbackT | None = None,
        method: str = "GET",
        headers: Mapping[AnyStr, Any] | Iterable[tuple[AnyStr, Any]] | None = None,
        body: bytes | str | None = None,
        cookies: CookiesT | None = None,
        meta: dict[str, Any] | None = None,
        encoding: str | None = "utf-8",
        priority: int = 0,
        dont_filter: bool = False,
        errback: Callable[[Failure], Any] | None = None,
        cb_kwargs: dict[str, Any] | None = None,
        flags: list[str] | None = None,
    )

Source from the content-addressed store, hash-verified

218 raise NotSupported("Response content isn't text")
219
220 def follow(
221 self,
222 url: str | Link,
223 callback: CallbackT | None = None,
224 method: str = "GET",
225 headers: Mapping[AnyStr, Any] | Iterable[tuple[AnyStr, Any]] | None = None,
226 body: bytes | str | None = None,
227 cookies: CookiesT | None = None,
228 meta: dict[str, Any] | None = None,
229 encoding: str | None = "utf-8",
230 priority: int = 0,
231 dont_filter: bool = False,
232 errback: Callable[[Failure], Any] | None = None,
233 cb_kwargs: dict[str, Any] | None = None,
234 flags: list[str] | None = None,
235 ) -> Request:
236 """
237 Return a :class:`~.Request` instance to follow a link ``url``.
238 It accepts the same arguments as ``Request.__init__()`` method,
239 but ``url`` can be a relative URL or a :class:`~scrapy.link.Link` object,
240 not only an absolute URL.
241
242 :class:`~.TextResponse` provides a :meth:`~.TextResponse.follow`
243 method which supports selectors in addition to absolute/relative URLs
244 and Link objects.
245 """
246 if encoding is None:
247 raise ValueError("encoding can't be None")
248 if isinstance(url, Link):
249 url = url.url
250 elif url is None:
251 raise ValueError("url can't be None")
252 url = self.urljoin(url)
253
254 return Request(
255 url=url,
256 callback=callback,
257 method=method,
258 headers=headers,
259 body=body,
260 cookies=cookies,
261 meta=meta,
262 encoding=encoding,
263 priority=priority,
264 dont_filter=dont_filter,
265 errback=errback,
266 cb_kwargs=cb_kwargs,
267 flags=flags,
268 )
269
270 def follow_all(
271 self,

Callers 1

follow_allMethod · 0.95

Calls 2

urljoinMethod · 0.95
RequestClass · 0.90

Tested by

no test coverage detected