MCPcopy Create free account
hub / github.com/ScrapeGraphAI/scrapecraft / validate_url

Function validate_url

backend/app/api/scraping.py:115–133  ·  view source on GitHub ↗

Validate if a URL is accessible.

(url: HttpUrl)

Source from the content-addressed store, hash-verified

113
114@router.post("/validate-url")
115async def validate_url(url: HttpUrl):
116 """Validate if a URL is accessible."""
117 try:
118 import httpx
119 async with httpx.AsyncClient(timeout=10.0) as client:
120 response = await client.head(str(url), follow_redirects=True)
121
122 return {
123 "url": str(url),
124 "valid": response.status_code < 400,
125 "status_code": response.status_code,
126 "content_type": response.headers.get("content-type", "")
127 }
128 except Exception as e:
129 return {
130 "url": str(url),
131 "valid": False,
132 "error": str(e)
133 }
134
135@router.post("/preview")
136async def preview_scraping(url: HttpUrl, selector: Optional[str] = None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected