Response class extends Selector to provide a unified response type across different fetching engines. It includes HTTP metadata alongside all the parsing capabilities of Selector.
Constructor
str
required
The URL of the response
str | bytes
required
The response content (automatically converted to bytes)
int
required
HTTP status code (e.g., 200, 404, 500)
str
required
HTTP status reason phrase (e.g., “OK”, “Not Found”)
Tuple[Dict[str, str], ...] | Dict[str, str]
required
Response cookies
Dict
required
Response headers
Dict
required
Request headers that were sent
str
default:"utf-8"
Character encoding to use for parsing
str
default:"GET"
HTTP method used (GET, POST, etc.)
List
default:"None"
List of redirect responses if any
Dict[str, Any]
default:"None"
Additional metadata dictionary. Must be a dict if provided
Any
Additional configuration passed to the
Selector base class (e.g., adaptive, huge_tree, keep_comments, etc.)Properties
status
reason
cookies
headers
request_headers
history
meta
request
body
Methods
follow()
dont_filter.
str
required
The URL to follow (can be relative, will be joined with current URL)
str
default:""
The session id to use. Defaults to the original request’s session id
Callable
default:"None"
Spider callback method to use. Defaults to the original request’s callback
int
default:"None"
The priority number to use, the higher the number, the higher priority to be processed first. Defaults to the original request’s priority
bool
default:"false"
If this request has been done before, disable the filter to allow it again
dict[str, Any]
default:"None"
Additional meta data to include in the request. Will be merged with the current response’s meta
bool
default:"true"
Set the current response URL as referer for the new request URL
Any
Additional Request arguments. Will be merged with the original session kwargs
Request object ready to be yielded
Example:
String Representation
__str__()
<status url>
Example:
Inheritance
SinceResponse inherits from Selector, all Selector methods and properties are available:
Selection Methods:
css()- Select with CSS selectorsxpath()- Select with XPathfind(),find_all()- Find by various filtersfind_by_text()- Find by text contentfind_by_regex()- Find by regex pattern
text- Element text contentattrib- Element attributeshtml_content- Inner HTMLtag- Tag nameparent,children,siblings- DOM navigation
get(),getall()- Serialize elementsget_all_text()- Get all text contentjson()- Parse JSONre(),re_first()- Extract with regex