--limit:
- Test crawl (
--limit N): bounded, runs in the foreground. Use it to verify a spider before a full run. - Production crawl (no
--limit): the full crawl. scrapai hands it to Pueue so it keeps running after you disconnect from SSH.
Pueue is an operational dependency for production crawls. If it is not installed, a
crawl without --limit exits with an error and tells you to install Pueue (see the README, “Long-running crawls”) or to test with --limit N.crawl
Run a spider by name.Arguments & Options
Spider name (from the database).
Project name containing the spider.
Output file path. Defaults to a date-based file in
data/<project>/<spider>/crawls/.Limit number of items. When set, runs a test crawl in the foreground.
Max runtime in seconds. Sets
CLOSESPIDER_TIMEOUT for a graceful stop.Proxy to use:
auto (smart escalation), none, or any named profile configured in .env (e.g. datacenter, residential, isp, mobile).Use a browser for JS-rendered sites and Cloudflare bypass. Sets
CLOUDFLARE_ENABLED=True.Additional Scrapy arguments, e.g.
"-s SETTING=value -L DEBUG".Clear the DeltaFetch cache to re-crawl all URLs. Also clears the checkpoint.
Save raw HTML in the output (
INCLUDE_HTML_IN_OUTPUT=True). Makes files larger.There is an internal
--detached flag used only when Pueue re-runs the command inside its worker. It is hidden and not meant for direct use.Test Crawl (with —limit)
- Runs in the foreground (not queued to Pueue).
- Stops after N items (
CLOSESPIDER_ITEMCOUNT). - Saves to the database. Verify with
./scrapai show bbc_co_uk. - Pass
-o <file>to also write results to a file.
Production Crawl (no limit)
- Queued to Pueue and run detached, so it survives an SSH disconnect.
- Exports to a date-based JSONL:
data/news/bbc_co_uk/crawls/crawl_28022026.jsonl(one file per day; same-day re-runs append). - Full HTML content is included only with
--save-html. - Checkpoint enabled — see Checkpoint Resume.
- Uploaded to S3 after a successful run, if S3 is configured.
crawl-status (below) for a higher-level view of progress across spiders, or the raw Pueue commands shown above.
Checkpoint Pause/Resume
Production crawls set a ScrapyJOBDIR checkpoint at data/<project>/<spider>/checkpoint/. To resume, run the same command — it picks up where it left off and continues writing to the same day’s file.
To stop a detached crawl, kill its Pueue task (pueue kill <task-id>); re-running the command resumes from the checkpoint. The checkpoint is removed automatically on successful completion.
scrapai guards two checkpoint edge cases automatically:
- Corrupted checkpoint (dupefilter persisted but the request queue is empty — a known Scrapy bug): the dupefilter is cleared so URLs can be re-discovered.
- Proxy type changed since the last run: the checkpoint is cleared so all URLs are retried with the new proxy.
Proxy Modes
--proxy-type is not a fixed list — it accepts auto, none, or any profile name you have configured in .env.
auto— smart escalation with expert-in-the-loop (default).none— direct connections only.- any other name — an explicit profile, used when blocked.
.env setup of named profiles.
Timeout
CLOSESPIDER_TIMEOUT for a graceful stop (finishes in-flight requests, saves the checkpoint).
Cloudflare / Browser Mode
For sites that need a browser (JS rendering or Cloudflare), use--browser or set CLOUDFLARE_ENABLED: true in the spider settings:
xvfb-run -a. If Xvfb is not installed, browser mode errors out and tells you to sudo apt-get install xvfb (or force headless with CLOUDFLARE_HEADLESS=true). See the Cloudflare Bypass guide.
Sitemap Spider
For spiders withUSE_SITEMAP: true, scrapai uses the sitemap spider and crawls from the XML sitemap instead of following links.
crawl-status
Show each detached crawl’s Pueue run state alongside how much it has downloaded. Readspueue status --json and joins it with the latest crawl file per spider.
Optional. Report just this spider (cheaper — only its crawl file is read). Omit to report every spider.
Only show crawls in this project.
- state — Pueue run state:
running,queued,paused,done,killed, orfailed. - downloaded — items in the latest crawl file.
- with-content — items whose extracted
contentis non-empty, with a percentage. The percentage excludes PDFs (collected links-only, no content by design), so a healthy crawl isn’t dragged down by PDFs. - start / end — Pueue task start and end times (
-when not yet ended). - last-item — time since the crawl file was last written — a liveness signal for a running crawl.
crawl-status only knows about crawls Pueue tracked (detached production crawls, labelled scrapai:<project>:<spider>). If Pueue is not installed it reports that there are no detached crawls to show.crawl-all
Run all active spiders in a project, sequentially and in the foreground.Project name.
Limit items per spider (test crawl for each).
crawl-all runs each spider inline, one after another — it does not queue them to Pueue.Output Formats
JSONL (Production)
Each line is a JSON object.url and content are the fields scrapai reads for status reporting; a spider’s own fields (title, html, timestamps, …) are also written per its schema.
--save-html, the raw HTML is included in each record.
Database (Test Crawl)
Test crawls save to thescraped_items table:
Troubleshooting
Spider Not Found
Pueue Not Installed
A production crawl needs Pueue. Install it (README: “Long-running crawls”), or run a bounded test with--limit N.
Checkpoint Corruption
If resume fails, clear the checkpoint and restart:Cloudflare Bypass Failed
Browser mode needs a display. On Linux servers install Xvfb (sudo apt-get install xvfb), or set CLOUDFLARE_HEADLESS=true in the spider settings.
Next Steps
View Scraped Data
Inspect and export crawl results
Cloudflare Bypass
Handle browser-protected sites