This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -44,9 +44,9 @@ class Viewport(BaseModel):
|
||||
|
||||
class InteractionsRequest(BaseModel):
|
||||
url: str = Field(..., description="Target URL (will be URL-decoded server-side).")
|
||||
returnType: Optional[Literal["screenshot", "html"]] = Field(
|
||||
returnType: Optional[Literal["screenshot", "html", "resulting_url"]] = Field(
|
||||
"screenshot",
|
||||
description="Return a PNG screenshot or HTML content.",
|
||||
description="Return a PNG screenshot, HTML content, or the resulting URL after interactions.",
|
||||
)
|
||||
viewport: Optional[Viewport] = None
|
||||
scrollX: Optional[int] = None
|
||||
@@ -124,7 +124,8 @@ async def screenshot_url(url: str, fullPage: bool = True, x_api_key: Optional[st
|
||||
description=(
|
||||
"Run a sequence of interactions (click/type) on a page.\n\n"
|
||||
"- `returnType=screenshot` returns `image/png`\n"
|
||||
"- `returnType=html` returns `text/html`"
|
||||
"- `returnType=html` returns `text/html`\n"
|
||||
"- `returnType=resulting_url` returns `application/json` with the final URL"
|
||||
),
|
||||
responses={
|
||||
200: {
|
||||
@@ -158,6 +159,11 @@ async def run_interactions(payload: InteractionsRequest, x_api_key: Optional[str
|
||||
if isinstance(result, dict) and result.get("status") == "error":
|
||||
raise HTTPException(status_code=500, detail=result.get("error", "Interaction failed"))
|
||||
|
||||
if return_type == "resulting_url":
|
||||
if not isinstance(result, dict):
|
||||
raise HTTPException(status_code=500, detail="Unexpected resulting_url response")
|
||||
return result
|
||||
|
||||
if return_type == "html":
|
||||
if not isinstance(result, str):
|
||||
raise HTTPException(status_code=500, detail="Unexpected HTML response")
|
||||
|
||||
Reference in New Issue
Block a user