rastrello ("rake", in Italian) watches Italian classified-ad marketplaces for the thing you are waiting for, and tells you the moment it shows up.
Scheduled crawling. Context-gated matching. Perceptual-hash dedup. Telegram alerts. A browsable web UI.
Classified-ad marketplaces are optimised for browsing, not for waiting. If the thing you want appears twice a month, is described five different ways, and is gone in an afternoon, the site's own saved search will not save you. It fires on keyword noise, forgets what it told you yesterday, and cannot tell that the "new" ad is last week's listing reposted at the same price.
rastrello crawls the sites on a schedule, decides what an ad is actually selling, extracts the attributes the seller buried in prose, notices when two ads are the same item or the same seller, and pings you on Telegram before anyone browsing manually gets there. One target in a recent run over a windsurf-gear hunt, four keyword variants for a 360 camera to film the sailing with: 750 raw cards → 356 that were genuinely about a 360 camera, and the fotocamera 360 query alone went from 180 to 34.
Three problems, really, and a saved-search email solves none of them. They are easiest to see through one concrete hunt, so the examples below are all from that windsurf run.
- A keyword is not a subject. One word routinely names several unrelated things: albero is Italian for mast, camshaft, family tree and Christmas tree, and a keyword alert on a general marketplace hands you all four. Deciding what an ad is about needs a rule that knows it has to be about windsurfing at all before its keywords count, and that "vendo albero windsurf e albero di natale" is still a mast. rastrello's matching engine does context gating, overlap-based exclusion and title-vs-description weighting, and tells you which of them fired.
- The attributes that decide it aren't fields. What separates the ad worth opening from the other forty is written into the seller's prose, where nothing can filter on it: for a mast, whether it is SDM or RDM, how long it is, how much carbon it has. The site gives you no column for any of that, so you open every ad. rastrello pulls those out into real columns with per-target regex rules, then filters, sorts and reports on them.
- The same item is many listings. Reposted after expiring, cross-posted to a second site, or listed twice by a dealer who would rather look like a private seller. They share no id, no title and often no price, but they share the seller's photographs. Perceptual hashing groups them; phone numbers join the seller across marketplaces where no account id survives.
Everything domain-specific lives in one YAML file: what to hunt, which sites, which fields, which filters, how the alerts read. The car tracker and the windsurf tracker in rastrello/configs/ are the same program with different configs, and they share no code paths.
- Config-driven, not hard-coded: targets, fields, filters, sources, alert text and the database schema all come from one YAML file, so a new tracked attribute is one entry that becomes a column, a filter widget, a line in every alert and a migration
- A matching engine, not a keyword search: accent- and case-insensitive matching with context gating, overlap-based exclusions,
title_onlyfor targets that drown in accessory ads, and ±80-character snippets showing why an ad appeared - An attributable filter funnel: every run reports
raw → after_date → after_region → after_price → after_fields → matchedper query, so a run that returns nothing points at a stage instead of a mystery - Duplicate and relist detection: 64-bit perceptual hashes over listing galleries, grouped by union-find, with a guard that ignores any image shared across too many distinct sellers (dealer logos and watermarks)
- Cross-source seller identity: site account ids, phone numbers and optionally shared photographs unioned into one seller, so the same item on two marketplaces is one row with two prices
- Multi-source and pluggable: Subito, AutoScout24 and Automobile.it ship, another site is 60-80 lines because the crawl loop, pagination, stop conditions and funnel are shared, and third-party adapters register via entry points (docs/SOURCES.md)
- Layered fetching:
requests→cloudscraper→ attached Chrome → headless Chrome, tried in the order you configure and each skipped cleanly when unavailable, with plain HTTP and robots.txt compliance as the defaults - Telegram alerts and a command bot: new listings, price drops and run summaries out,
/set since albero 2026-07-01back in, with the settable list generated from your own config and applied on the next run without a restart - A web UI: grid or duplicate-grouped, filters generated from your fields, a region picker with macro-area grouping, image galleries with a lightbox, per-seller and per-number pages, and a light or dark theme that follows the system
- Real migrations:
PRAGMA user_versionfor core changes and config-diffed columns for domain fields, so adding a field migrates itself and removing one is reported rather than silently dropped - Privacy-first defaults: phone collection off, and when it is on, numbers are stored as keyed hashes so identity matching still works and no directory of phone numbers exists (docs/LEGAL.md)
Python 3.11 or newer, and a Telegram bot token and chat id if you want alerts (@BotFather). Nothing else: browser dependencies are an extra, installed only if a site you configure needs one.
git clone https://github.com/tintando/rastrello
cd rastrello && pip install -e .
rastrello init --example windsurf-it # or: --example cars-it, or bare for minimal
cp .env.example .env # then fill in the Telegram token and chat id
rastrello migrate
rastrello run --dry-run # crawl and print the funnel; no writes, no alerts
rastrello run # for real, once the funnel looks right
rastrello web # http://localhost:8080Read the funnel before trusting anything. One target of the four in the windsurf example, trimmed at the …:
$ rastrello run --dry-run
=== filter funnel (raw → after_date → after_region → after_price → after_fields → matched) ===
…
subito:camera360 since=2026-06-01 regions=['anywhere'] pages=25
insta360 450 → 450 → 450 → 450 → 450 → 291
fotocamera 360 180 → 155 → 155 → 155 → 155 → 34
gopro max 90 → 64 → 64 → 64 → 64 → 29
ricoh theta 30 → 4 → 4 → 4 → 4 → 2
TOTAL 750 → 673 → 673 → 673 → 673 → 356
…
=== 498 distinct listings would be stored ===
Every stage is named, so a disappointing number points at a stage rather than at a mystery. Here the date window takes 77 cards and the matching engine takes 317 more, and it falls unevenly: hardest on fotocamera 360, two ordinary words where roughly four ads in five that carry them are selling something else, and lightest on insta360, a brand name that mostly means what it says.
cp .env.example .env # fill it in
rastrello init --example cars-it # writes ./config.yaml, mounted read-only
docker compose up -d # scraper on the crontab schedule, plus the web UI
docker compose --profile bot up -d # and the Telegram command botThe image runs as a non-root user and carries no browser; set RASTRELLO_IMAGE_TARGET=browser in .env to build the Chrome-carrying stage if a source you configure needs one. Without Docker, a crontab line does the same job: */30 * * * * cd /path/to/hunt && rastrello run >> data/cron.log 2>&1. The runbook lives in docs/OPERATIONS.md.
git clone https://github.com/tintando/rastrello
cd rastrello && python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest # the whole suite, offlineNo test touches the network. Scraper tests run against recorded __NEXT_DATA__ fixtures in tests/fixtures/; when a site changes shape, a failed run leaves the offending page in data/debug_snapshots/, and trimming one down into a fixture turns the breakage into a regression test.
rastrello scout "albero" --show rejectedFetches one query and prints, per ad, the verdict the rules would give it, including why each reject was rejected ("no target's context matches" versus "context ok but no target term"). This is how the shipped rules were written. Four of the 28 rejects a bare albero produces, which is exactly why the shipped config asks for albero windsurf instead:
$ rastrello scout "albero" --show rejected
GET https://www.subito.it/annunci-italia/vendita/usato/?q=albero&order=datedesc
403,442 chars
payload: yes · orderIndex=0 · 30 cards
30 listings · dates 2026-08-05T18:49:13 … 2026-08-05T20:05:16 · newest-first: yes
in window (>= 2026-06-01): 30
regions: lombardia=7, toscana=5, puglia=3, sicilia=3, lazio=3, piemonte=2, emilia-romagna=2, veneto=2, campania=1, trentino-alto-adige=1, liguria=1
✗ albero italkit am6
€100 · 2026-08-05T19:36:19 · lazio/Pico
→ rejected: no target's context matches
✗ Albero cardanico o di trasmissione renault 4x4
€200 · 2026-08-05T19:21:36 · puglia/Ceglie Messapica
→ rejected: no target's context matches
✗ Land Rover Defender 90 benz/gpl
€22000 · 2026-08-05T19:20:16 · lombardia/Milano
→ rejected: context ok (camera360) but no target term
✗ albero di natale con luci annesse
€85 · 2026-08-05T19:04:53 · lombardia/Binasco
→ rejected: no target's context matches
…
verdicts: reject=28, accept=2, albero=2
A moped crankshaft, a driveshaft and a Christmas tree, all three of them literally alberi, and a Land Rover whose ad talks about cameras enough to clear the 360-camera target's context gate and then names no camera. Two ads out of thirty were masts.
The full schema is docs/CONFIGURATION.md. The shape of it:
fields: # → DB columns + UI filters + notification lines
- {key: mast_type, type: enum, values: [sdm, rdm], label: Mast type, filter: select}
- {key: length_cm, type: int, label: Length, unit: cm, filter: range,
notify: "{value} cm"}
targets: # a `defaults:` block above supplies whatever is omitted
- key: albero
queries: ["albero windsurf", "albero sdm"]
regions: [lazio] # this one is heavy to ship
match:
terms: ["\\balber[oi]\\b"]
exclude: ["\\balber[oi]\\s+(motore|di\\s+natale)"]
context: [windsurf, "\\bsdm\\b"]
extract:
mast_type: {pattern: "\\b(sdm|rdm)\\b", transform: lower}
sources:
- name: subito
fetch: [requests, cloudscraper]
respect_robots: true
rate_limit: {min: 3, max: 8}Credentials are referenced by environment-variable name, never written in the config, so a hunt config is safe to commit and share.
Three layers resolve every search parameter: defaults → the target's own keys → data/filters.json (which the Telegram bot writes). The override file is re-read at the start of every crawl, so a filter changed from your phone applies to the next run with no restart.
All commands
| Command | Does |
|---|---|
rastrello init |
Write a starter config (--example cars-it / windsurf-it) |
rastrello migrate |
Create or update the schema (--check to dry-run) |
rastrello run |
Crawl, store, notify (--dry-run, --since, --target, --no-notify, --test-telegram) |
rastrello scout |
Fetch one query and explain every verdict |
rastrello web |
Serve the browser UI |
rastrello bot |
Run the Telegram command bot |
rastrello backfill |
Re-derive stored listings from saved payloads (--hash, --rematch) |
Package layout
rastrello/
├── cli.py # subcommands: run · scout · web · bot · init · migrate · backfill
├── hunt.py # config.yaml → typed Hunt/Target/FieldSpec, validated
├── settings.py # environment and paths: everything that isn't the hunt
│
├── pipeline/
│ ├── run.py # orchestration: crawl → store → identity → dedup → notify
│ ├── filters.py # filter_verdict and the funnel stages, in one place
│ ├── matching.py # the rule engine: folding, context, overlap exclusion
│ ├── specs.py # config-driven regex extraction into fields
│ ├── dedup.py # perceptual hashing, union-find grouping, logo guard
│ ├── identity.py # cross-listing and cross-site seller resolution
│ ├── phones.py # canonicalization and the keyed hashing that is default
│ ├── enrich.py # detail-page enrichment, off unless asked for
│ └── backfill.py # replay stored payloads through the current rules
│
├── sources/
│ ├── base.py # the Listing dataclass and the adapter contract
│ ├── nextjs.py # shared __NEXT_DATA__ crawl: pagination, stop conditions
│ ├── fetchers.py # requests | cloudscraper | chrome-cdp | chrome, in order
│ ├── browser.py # Chrome plumbing: attach, socat forward, tab cleanup
│ ├── paths.py # field_map path resolution and value parsers
│ ├── subito.py # the reference adapter: read this one first
│ ├── autoscout24.py # path-searched, no dates, phones in the card payload
│ ├── automobile.py # path-searched, plain HTTP, paginates with p=
│ └── registry.py # built-ins plus entry-point plugins
│
├── db/ # schema.py · migrations.py · store.py, all built from fields:
├── notify/ # base.py · telegram.py · render.py, driven by fields:
├── bot/ # app.py · table.py, /set generated from the config
├── webapp/ # app.py · queries.py · templates/ · static/
├── i18n/ # en.yaml · it.yaml, UI chrome only
├── geo/ # it.yaml: regions, macro-areas, postal and province fallback
└── configs/ # example-windsurf-it.yaml · example-cars-it.yaml · minimal.yaml
The matching engine. Text is folded, meaning lowercased and de-accented, character by character, so offsets stay aligned with the original and snippets can be cut from untouched source text. A target's context patterns are checked over the whole ad before its terms are, so an ad that isn't about windsurfing at all can't match however many of the words it contains. Exclusions are an overlap check against the term hit's own span rather than a document-level veto, which is what keeps "albero windsurf e albero di natale" counting as a mast. Title hits beat description hits, so the reported origin is always the strongest evidence there is.
Normalize, never filter. Adapters turn a card into a Listing and stop. Filtering happens once, in pipeline/filters.py, where a rejection can be counted and named, which is what makes the funnel worth reading. An adapter that dropped an ad by returning None would take the reason with it.
The crawl stops early, carefully. Results come back newest-first, so a page that reaches entirely past your date window means every later page does too. That ordering is verified against the data, within the page and against the previous one, rather than assumed from the sort parameter, and the early stop disables itself with a warning if a site ever stops honouring it. A page whose ads are all already seen means the site ignored the page parameter, and the crawl stops rather than looping.
Re-checking after the merge. An ad found by a nationwide crawl may mention something a geofenced target also tracks. It only counts for that target if it also satisfies that target's filters, so every claimed target is re-run through the same verdict function. Without it the geofence would hold only for whichever crawl found the ad first.
The "gone" sweep is guarded twice. Listings this run didn't see are marked inactive, but only when every target scraped cleanly (a partial run sees nothing of the rest, which must not read as "everything is gone"), and only within the earliest date cutoff in play (ads older than that are never re-crawled, so their absence says nothing).
Identity before dedup. Image dedup's logo guard excludes any hash seen across more than four distinct sellers, so it needs sellers resolved first. That ordering is the reason identity.py runs before dedup.py and, optionally, again afterwards to fold the fresh duplicate groups back in.
- It reads and tells you; it does not act. No bidding, no messaging, no buying, and nothing here authenticates anywhere. Contact happens in your hands, in the site's own UI.
- Italian marketplaces only, so far. The engine is country-agnostic (geo data is
geo/<country>.yaml, phone rules are per-country), but onlyitships, because it's what the shipped configs hunt. - Both example configs assume Next.js payloads. Sites that render server-side HTML need a
BaseScrapersubclass rather than aNextDataScraperone, and then you own pagination yourself. - AutoScout24 and Automobile.it publish no publication date. The date cutoff can't stop pagination there, so those crawls are slower and "gone" detection leans on the full page walk.
- Image dedup is O(n²) within a bucket. Fine at the tens of thousands of listings a personal hunt reaches; it would need an LSH index beyond that.
- The web UI is read-only and unauthenticated. It binds
0.0.0.0for Docker's sake, so put it behind something if the machine isn't yours alone. - One locale for the UI chrome at a time, and only
enanditship.
Deeper documentation: docs/CONFIGURATION.md for the config schema field by field, docs/SOURCES.md for writing an adapter for another marketplace, docs/OPERATIONS.md for the data model, the runbook and the gotchas that cost real debugging time, and docs/LEGAL.md for the scraping posture and what this tool will not do.
Built from two private trackers that grew in opposite directions, one toward more marketplaces and the other toward better rules, and that were the same program the whole time. Merging them is what produced the config layer: every place the two disagreed turned out to be something that should have been data.
Python, SQLite, Flask, BeautifulSoup, Pillow and ImageHash, PyYAML, waitress. Selenium, cloudscraper and undetected-chromedriver are optional extras, pulled in only by the browser fetch strategies. No ORM: the schema is generated from the config, and the SQL is the interesting part.
MIT. See LICENSE.
