콘텐츠로 이동

Python SDK

HydraSkill 공식 Python SDK입니다. 동기(sync)와 비동기(async) 작업을 모두 지원합니다.

Terminal window
pip install hydraskill
from hydraskill import ProxyClient
client = ProxyClient(api_key="sk-...")
# 프록시 가져오기
proxy = client.get_proxy(target="amazon.com", session_lock=True)
# requests와 함께 사용
import requests
resp = requests.get("https://amazon.com", proxies=proxy.to_dict())
# 작업이 끝나면 반환
proxy.release()
from hydraskill import AsyncProxyClient
client = AsyncProxyClient(api_key="sk-...")
async def scrape():
proxy = await client.get_proxy(target="amazon.com")
async with httpx.AsyncClient(proxies=proxy.to_httpx()) as http:
resp = await http.get("https://amazon.com")
await proxy.release()
from hydraskill import ProxyClient
from playwright.sync_api import sync_playwright
client = ProxyClient()
proxy = client.get_proxy(target="amazon.com", session_lock=True)
with sync_playwright() as p:
browser = p.chromium.launch(proxy={
"server": proxy.to_playwright_server(),
"username": proxy.username,
"password": proxy.password,
})
page = browser.new_page()
page.goto("https://amazon.com")
client = ProxyClient(
api_key="sk-...",
timeout=30, # 요청 타임아웃 (초)
max_retries=3, # 일시적 오류 시 재시도
base_url="https://api.hydraskill.ai", # 커스텀 엔드포인트
)
from hydraskill.exceptions import (
AuthenticationError,
RateLimitError,
ProxyExhaustedError,
InsufficientBalanceError,
)
try:
proxy = client.get_proxy(target="example.com")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after_ms}ms")
except InsufficientBalanceError:
print("Upgrade your plan or add traffic")