schemas.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from typing import Any, Literal, Optional
  2. from pydantic import BaseModel, Field, HttpUrl
  3. WaitUntilValue = Literal["load", "domcontentloaded", "networkidle", "commit"]
  4. class VisitRequest(BaseModel):
  5. url: HttpUrl
  6. screenshot: bool = False
  7. waitUntil: WaitUntilValue = Field(default="load")
  8. waitTime: int = Field(
  9. default=0,
  10. ge=0,
  11. le=60,
  12. description=(
  13. "Extra seconds to wait AFTER waitUntil resolves. "
  14. "Useful for SPAs (e.g. MercadoLibre) that need extra time to hydrate polycards "
  15. "after the network goes idle. Max 60s."
  16. ),
  17. )
  18. proxy: Optional[str] = None
  19. proxyAuth: Optional[dict[str, Any]] = None
  20. incognito: bool = False
  21. screenshotSelector: Optional[str] = None
  22. screenshotDelay: int = Field(
  23. default=0,
  24. ge=0,
  25. le=60000,
  26. description="Milliseconds to wait before taking the screenshot.",
  27. )
  28. clickSelector: Optional[str] = None
  29. selectorTimeout: int = Field(
  30. default=1000,
  31. ge=100,
  32. le=30000,
  33. description="Milliseconds to wait for selectors used in screenshotSelector or clickSelector.",
  34. )
  35. class ArasResponse(BaseModel):
  36. status: str
  37. message: str
  38. data: Any = None
  39. extra: Any = None
  40. code: str = "UNKNOWN_CODE"