- Python 100%
| zivi | ||
| .gitignore | ||
| CLAUDE.md | ||
| Pipfile | ||
| Pipfile.lock | ||
| README.md | ||
zivi
Crawls Zivildienst Einsätze from https://ziviconnect.admin.ch/zdp/einsatz into SQLite.
Setup
PIPENV_VENV_IN_PROJECT=1 pipenv install
pipenv run playwright install chromium # or: sudo apt install chromium
A system Chromium on PATH (chromium, chromium-browser, google-chrome) is used
automatically; set CHROMIUM_PATH to point at any other binary.
Usage
pipenv run zivi login # AGOV QR code in the terminal
pipenv run zivi crawl --from 01.11.2026 --to 31.03.2027 # search + details into zivi.db
pipenv run zivi stats
pipenv run zivi reparse # rebuild tables from stored raw JSON
pipenv run zivi embed # vectors for all listing texts (OpenAI)
pipenv run zivi explore --canton GR,VS --housing # find your favorites by picking examples
pipenv run zivi search "work with animals" -n 10 # plain similarity search
embed, explore and search need OPENAI_API_KEY in the environment.
crawl logs in by itself if the saved session (.state/session.json) has expired. The site
only accepts a Monday as start and a Friday as end, so the range is shrunk to the nearest
Monday/Friday inside it.
How it works
ziviconnect is an Angular app on top of a JSON API. After the AGOV login the crawler reads the app's access token from the browser and calls the API directly:
POST /web-zdp/api/pflichtenheft-search-detail/searchreturns at most 150 hits, while.../search-facetsreports the real count. The search is split along filters (weekend work, night work, meals, housing, ...) until every part is below 150. The reported count is per index entry and a listing can appear several times, so the number of distinct listings is lower (Nov 2026 to Mar 2027: 3870 entries, 2853 listings).- Language, special programs (Lager, Ausland, long Einsatz) and driving licence are only available as search filters, so extra filtered searches add them as tags.
GET .../pflichtenheft/{id}returns the full record, which is split into tables.
Database
| table | content |
|---|---|
listing |
one Einsatz offer (Pflichtenheft): conditions, requirements, contact |
organization |
Einsatzbetrieb: name, description, website, address |
task |
activities of a listing with their share in percent |
location |
Einsatz addresses of a listing |
tag |
code lists: task_area, field, course, contact_method, language, program, driving_licence |
search_run |
each crawl with its date range |
search_hit |
which listings were available in which search run |
Columns derived with regex from the free text: listing.min_age, listing.driving_category,
listing.required_languages, organization.website. listing.full_text collects all
descriptive text and is meant as input for embeddings. listing.raw_json keeps the original
record, so zivi reparse can apply parser improvements without crawling again.
Example: outdoor listings in the mountains with housing, no weekend work:
SELECT l.number, l.title, o.name, GROUP_CONCAT(DISTINCT loc.canton) AS cantons
FROM listing l
JOIN organization o ON o.number = l.organization_number
JOIN tag t ON t.listing_id = l.id AND t.kind = 'task_area' AND t.code = 'ARBEIT_IM_FREIEN'
JOIN location loc ON loc.listing_id = l.id
WHERE l.housing = 1 AND l.weekend_work = 'N' AND loc.canton IN ('GR', 'VS', 'BE', 'UR', 'TI')
GROUP BY l.id;
Finding jobs you like: zivi explore
Each round shows 8 jobs from the current set: 6 from the two opposite ends of the three axes along which the set differs most (e.g. forest work vs. care, kitchen vs. group home) and 2 from its middle. Each job shows how many jobs of the set it stands for (those most similar to it). The header shows the set size, its spread compared to the start and roughly how many picks are left until about 15 jobs remain.
<number>keeps the 25% of the set most similar to that job (--keepchanges the share)-<number>removes that job and everything it stands forbgoes back one step,llists the current setpwrites the current set with contact details and tasks toshortlist-<time>.md
With 4 picks, about 30 descriptions get 2853 jobs down to about 12. Filters such as
--canton GR,VS, --housing, --no-weekend, --program lager or --language de limit the
set before the first round. The DE/FR/IT difference is removed from the vectors, otherwise
the most "different" jobs would mostly be the Italian and French ones (--keep-language
turns this off).
Embeddings use text-embedding-3-large on the listing text plus a header with places, task
areas and programs. They are stored in the embedding table; zivi embed only sends new or
changed texts.