Represents an HTTP request, which is usually generated in a Spider and executed by the Downloader, thus generating a :class:`~scrapy.http.Response`.
| 82 | |
| 83 | |
| 84 | class Request(object_ref): |
| 85 | """Represents an HTTP request, which is usually generated in a Spider and |
| 86 | executed by the Downloader, thus generating a :class:`~scrapy.http.Response`. |
| 87 | """ |
| 88 | |
| 89 | __attrs_and_slots = ("callback", "dont_filter", "errback", "method", "priority") |
| 90 | attributes: tuple[str, ...] = ( |
| 91 | "url", |
| 92 | "headers", |
| 93 | "body", |
| 94 | "cookies", |
| 95 | "meta", |
| 96 | "encoding", |
| 97 | "flags", |
| 98 | "cb_kwargs", |
| 99 | *__attrs_and_slots, |
| 100 | ) |
| 101 | """A tuple of :class:`str` objects containing the name of all public |
| 102 | attributes of the class that are also keyword parameters of the |
| 103 | ``__init__()`` method. |
| 104 | |
| 105 | Currently used by :meth:`.Request.replace`, :meth:`.Request.to_dict` and |
| 106 | :func:`~scrapy.utils.request.request_from_dict`. |
| 107 | """ |
| 108 | |
| 109 | __slots__ = ( |
| 110 | "__weakref__", |
| 111 | "_body", |
| 112 | "_cb_kwargs", |
| 113 | "_cookies", |
| 114 | "_encoding", |
| 115 | "_flags", |
| 116 | "_headers", |
| 117 | "_meta", |
| 118 | "_url", |
| 119 | *__attrs_and_slots, |
| 120 | ) |
| 121 | del __attrs_and_slots |
| 122 | |
| 123 | def __init__( |
| 124 | self, |
| 125 | url: str, |
| 126 | callback: CallbackT | None = None, |
| 127 | method: str = "GET", |
| 128 | headers: Mapping[AnyStr, Any] | Iterable[tuple[AnyStr, Any]] | None = None, |
| 129 | body: bytes | str | None = None, |
| 130 | cookies: CookiesT | None = None, |
| 131 | meta: dict[str, Any] | None = None, |
| 132 | encoding: str = "utf-8", |
| 133 | priority: int = 0, |
| 134 | dont_filter: bool = False, |
| 135 | errback: Callable[[Failure], Any] | None = None, |
| 136 | flags: list[str] | None = None, |
| 137 | cb_kwargs: dict[str, Any] | None = None, |
| 138 | ) -> None: |
| 139 | self._encoding: str = encoding # this one has to be set first |
| 140 | self.method: str = str(method).upper() |
| 141 | self._set_url(url) |
no outgoing calls
searching dependent graphs…