-
-
Notifications
You must be signed in to change notification settings - Fork 0
18 extends
Zuko edited this page Jan 21, 2026
·
1 revision
Extended functionality và specialized implementations
Anti-detection HTTP session using curl_cffi:
from core.extends import CurlSslAntiDetectSession
session = CurlSslAntiDetectSession(
impersonate='chrome110',
timeout=30
)
# GET request
response = session.get('https://api.example.com')
print(response.text)
# POST request
response = session.post(
'https://api.example.com/data',
json={'key': 'value'}
)
# With headers
response = session.get(
'https://api.example.com',
headers={'User-Agent': 'Custom'}
)- Browser impersonation (Chrome, Firefox, Safari)
- TLS fingerprint randomization
- Anti-bot detection
- Session persistence
from core.extends import CurlSslAntiDetectSession
session = CurlSslAntiDetectSession()
# Simple GET
response = session.get('https://example.com')
print(response.status_code)
print(response.text)# Impersonate Chrome 110
session = CurlSslAntiDetectSession(impersonate='chrome110')
# Impersonate Firefox
session = CurlSslAntiDetectSession(impersonate='firefox')
# Impersonate Safari
session = CurlSslAntiDetectSession(impersonate='safari')from core.taskSystem import AbstractTask
from core.extends import CurlSslAntiDetectSession
class ScrapingTask(AbstractTask):
def handle(self):
session = CurlSslAntiDetectSession(impersonate='chrome110')
try:
response = session.get('https://example.com')
data = response.json()
# Process data...
except Exception as e:
self.fail(f'Request failed: {e}')
def _performCancellationCleanup(self):
pass# Use in background tasks
class MyTask(AbstractTask):
def handle(self):
session = CurlSslAntiDetectSession()
response = session.get(url)
# Set appropriate timeout
session = CurlSslAntiDetectSession(timeout=30)
# Handle exceptions
try:
response = session.get(url)
except Exception as e:
logger.error(f'Request failed: {e}')# Don't use in UI thread
class MyHandler(BaseCtlHandler):
def onButtonClicked(self):
session = CurlSslAntiDetectSession() # Wrong! Use in task
# Don't forget timeout
session = CurlSslAntiDetectSession() # No timeout!- AbstractTask - Background tasks
- NetworkManager - UI thread networking