refactor: replace's Selector inpt (text/body) with 1 argument called content

This commit is contained in:
Karim shoair
2025-07-29 06:08:15 +03:00
parent 9e9ba9ab10
commit b9c7a5af2e
5 changed files with 30 additions and 42 deletions
+5 -5
View File
@@ -103,8 +103,7 @@ class Response(Selector):
def __init__(
self,
url: str,
text: str,
body: bytes,
content: str | bytes,
status: int,
reason: str,
cookies: Union[Tuple[Dict[str, str], ...], Dict[str, str]],
@@ -122,10 +121,11 @@ class Response(Selector):
self.headers = headers
self.request_headers = request_headers
self.history = history or []
encoding = ResponseEncoding.get_value(encoding, text)
encoding = ResponseEncoding.get_value(
encoding, content.decode("utf-8") if isinstance(content, bytes) else content
)
super().__init__(
text=text,
body=body,
content=content,
url=adaptive_domain or url,
encoding=encoding,
**selector_config,