Batch web scraping API
एक call में 10,000 URLs तक भेजें। हर page साफ़ data के रूप में वापस पाएँ।
import requestsjob = requests.post( "https://api.spicrawl.com/v1/batch", headers="Authorization": "Bearer spicrawl_live_…", json={ "urls": ["https://example.com/one", "https://example.com/two"], "js_render": True, },).json()# Poll GET /v1/batch/{id} until status is "completed"print(job["id"], job["total_items"])यह कैसे काम करता है
- अपने URLs भेजें
POST /v1/batchपर। आपको तुरंत एक job ID वापस मिलती है। - Job जाँचें जब तक उसका status
completed,failedयाcancelledन हो जाए। - Results पढ़ें JSON Lines के रूप में, एक बार में एक page,
X-Next-Cursorके साथ।
curl https://api.spicrawl.com/v1/batch \
-H "Authorization: Bearer $SPICRAWL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "catalog-refresh",
"urls": ["https://example.com/products/1", "https://example.com/products/2"],
"response_format": "markdown"
}'import os, time, requests
API = "https://api.spicrawl.com"
H = {"Authorization": f"Bearer {os.environ['SPICRAWL_API_KEY']}"}
job = requests.post(f"{API}/v1/batch", headers=H, json={
"urls": ["https://example.com/products/1", "https://example.com/products/2"],
"response_format": "markdown",
}, timeout=60).json()
while job["status"] not in ("completed", "failed", "cancelled"):
time.sleep(5)
job = requests.get(f"{API}/v1/batch/{job['id']}", headers=H, timeout=30).json()
results = requests.get(f"{API}/v1/batch/{job['id']}/results", headers=H, timeout=120)
print(results.text) # JSON Lines: one result per linespicrawl batch submit urls.txt --format markdown --wait
spicrawl batch results <job-id> --all -o results.jsonlअपनी key SPICRAWL_API_KEY में रखें। आपकी key को batch scope चाहिए।
हर item क्या कर सकता है
- Formats:
html(default),markdown,textयाjson। - सफ़ाई:
main_content_only,include_tagsऔरexclude_tagsMarkdown और text पर काम करते हैं। - JavaScript: जिन pages को browser चाहिए उनके लिए
js_render: trueset करें। - प्रति-URL settings: हर URL को उसकी अपनी settings और एक
external_idदेने के लिएurlsकी जगहitemsभेजें।
जानने लायक बातें
- Batch पर नहीं: extraction, screenshots, browser actions और sessions। जो job इन्हें माँगती है, उसे कुछ भी charge होने से पहले 400 के साथ refuse कर दिया जाता है। उन pages के लिए single scrapes इस्तेमाल करें।
- Results expire हो जाते हैं job पूरी होने के 72 hours बाद।
- Crawling नहीं। Spicrawl URLs नहीं ढूँढता और links follow नहीं करता। List आप भेजते हैं।
- Pricing: beta के दौरान free। हर सफल item उतने ही credits लेता है जितने एक single scrape।
अक्सर पूछे जाने वाले सवाल
एक batch job में कितने URLs हो सकते हैं?
हर call में 10,000 URLs तक। उन्हें urls में list के रूप में भेजें, या items के रूप में जब हर URL को अपनी settings या match करने के लिए external_id चाहिए।
Batch job कौन से formats लौटाता है?
हर item html (default), markdown, text या json के रूप में आता है। Markdown और text वही conversion इस्तेमाल करते हैं जो single scrape में होता है।
Batch results कितने समय तक रखे जाते हैं?
For 72 hours after the job finishes. Read them with GET /v1/batch/{id}/results, which returns JSON Lines one page at a time.
क्या batch job fields निकाल सकता है या buttons click कर सकता है?
नहीं। Extraction, screenshots, browser actions और sessions batch पर नहीं चलते। जो job इन्हें माँगता है उसे कुछ भी charge होने से पहले 400 के साथ refuse कर दिया जाता है। उन pages के लिए single scrapes इस्तेमाल करें।
क्या batch पूरी website crawl करता है?
नहीं। Spicrawl URLs नहीं ढूँढता और links follow नहीं करता। आप अपनी चाही हुई URLs की list भेजते हैं।