refactor(Fetcher): Fix the issue of caching impersonation state + Less code duplication

It now creates a session with each request, but at the same time, it's still faster than the fetcher in v0.2.99 by 20% with more features enabled.
This commit is contained in:
Karim shoair
2025-07-06 02:21:15 +03:00
parent 18e56a8c50
commit 6d79927233
2 changed files with 36 additions and 320 deletions
+5 -4
View File
@@ -20,6 +20,7 @@ from scrapling.engines import (
from scrapling.engines.toolbelt import BaseFetcher, Response
__FetcherClientInstance__ = _FetcherClient()
__AsyncFetcherClientInstance__ = _AsyncFetcherClient()
class Fetcher(BaseFetcher):
@@ -34,10 +35,10 @@ class Fetcher(BaseFetcher):
class AsyncFetcher(BaseFetcher):
"""A basic `Fetcher` class type that can only do basic GET, POST, PUT, and DELETE HTTP requests based on `curl_cffi`."""
get = _AsyncFetcherClient.get
post = _AsyncFetcherClient.post
put = _AsyncFetcherClient.put
delete = _AsyncFetcherClient.delete
get = __AsyncFetcherClientInstance__.get
post = __AsyncFetcherClientInstance__.post
put = __AsyncFetcherClientInstance__.put
delete = __AsyncFetcherClientInstance__.delete
class StealthyFetcher(BaseFetcher):