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

Function scrape_urls

backend/app/api/workflow_v2.py:83–119  ·  view source on GitHub ↗

Scrape multiple URLs with a given prompt. Request body: { "pipeline_id": "string", "urls": ["url1", "url2"], "extraction_prompt": "What data to extract" }

(
    request: Dict[str, Any],
    connection_manager: ConnectionManager = Depends(lambda: ConnectionManager()),
    current_user: User = Depends(get_current_user)
)

Source from the content-addressed store, hash-verified

81
82@router.post("/scrape")
83async def scrape_urls(
84 request: Dict[str, Any],
85 connection_manager: ConnectionManager = Depends(lambda: ConnectionManager()),
86 current_user: User = Depends(get_current_user)
87) -> Dict[str, Any]:
88 """
89 Scrape multiple URLs with a given prompt.
90
91 Request body:
92 {
93 "pipeline_id": "string",
94 "urls": ["url1", "url2"],
95 "extraction_prompt": "What data to extract"
96 }
97 """
98 pipeline_id = request.get("pipeline_id")
99 urls = request.get("urls", [])
100 extraction_prompt = request.get("extraction_prompt", "Extract all relevant data")
101
102 if not pipeline_id or not urls:
103 raise HTTPException(status_code=400, detail="pipeline_id and urls are required")
104
105 use_tools = os.getenv("USE_TOOLS_AGENT", "false").lower() == "true"
106 manager = get_enhanced_workflow_manager(connection_manager, use_tools)
107
108 try:
109 results = await manager.scrape_urls(pipeline_id, urls, extraction_prompt)
110
111 return {
112 "success": True,
113 "urls_scraped": len(urls),
114 "results": results,
115 "agent_mode": "tools-based" if use_tools else "state-based"
116 }
117
118 except Exception as e:
119 raise HTTPException(status_code=500, detail=str(e))
120
121
122@router.get("/tools")

Callers

nothing calls this directly

Calls 3

ConnectionManagerClass · 0.90
scrape_urlsMethod · 0.80

Tested by

no test coverage detected