tutti-scraper 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tutti_scraper-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +26 -0
- tutti_scraper-0.1.0/.github/workflows/ci.yml +39 -0
- tutti_scraper-0.1.0/.github/workflows/e2e.yml +28 -0
- tutti_scraper-0.1.0/.github/workflows/release.yml +90 -0
- tutti_scraper-0.1.0/.gitignore +16 -0
- tutti_scraper-0.1.0/CHANGELOG.md +54 -0
- tutti_scraper-0.1.0/CODE_OF_CONDUCT.md +36 -0
- tutti_scraper-0.1.0/CONTRIBUTING.md +84 -0
- tutti_scraper-0.1.0/LICENSE +23 -0
- tutti_scraper-0.1.0/PKG-INFO +510 -0
- tutti_scraper-0.1.0/PULL_REQUEST_TEMPLATE.md +10 -0
- tutti_scraper-0.1.0/Pipfile +20 -0
- tutti_scraper-0.1.0/Pipfile.lock +1006 -0
- tutti_scraper-0.1.0/README.md +476 -0
- tutti_scraper-0.1.0/SECURITY.md +25 -0
- tutti_scraper-0.1.0/pyproject.toml +86 -0
- tutti_scraper-0.1.0/tests/conftest.py +104 -0
- tutti_scraper-0.1.0/tests/test_cli.py +195 -0
- tutti_scraper-0.1.0/tests/test_client.py +231 -0
- tutti_scraper-0.1.0/tests/test_e2e.py +73 -0
- tutti_scraper-0.1.0/tests/test_io.py +229 -0
- tutti_scraper-0.1.0/tests/test_listing_url.py +40 -0
- tutti_scraper-0.1.0/tests/test_price_constraint.py +30 -0
- tutti_scraper-0.1.0/tests/test_scrape.py +150 -0
- tutti_scraper-0.1.0/tests/test_scraper.py +208 -0
- tutti_scraper-0.1.0/tests/test_search.py +89 -0
- tutti_scraper-0.1.0/tutti_scraper.py +712 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something isn't working — e.g. wrong/missing data, a crash, or tutti.ch changed their API
|
|
4
|
+
title: ""
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: ""
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
**Exact command you ran** (CLI flags, or the `scrape(...)` call if using it as a library)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**What happened**
|
|
15
|
+
|
|
16
|
+
**What you expected instead**
|
|
17
|
+
|
|
18
|
+
**Version** (`tutti-scraper --version`, or the git commit if running from source)
|
|
19
|
+
|
|
20
|
+
**If this looks like the API changed:** paste the raw response you got back
|
|
21
|
+
(e.g. from `-v`/`--verbose`, or by hitting the endpoint directly with curl).
|
|
22
|
+
This is the fastest way to confirm whether tutti.ch changed something on
|
|
23
|
+
their end vs. a bug in this project.
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
pip install "requests~=2.34" "pytest~=9.1" "pytest-cov~=7.1" "responses~=0.26" \
|
|
27
|
+
"ruff~=0.15" "mypy~=2.1" "types-requests~=2.33"
|
|
28
|
+
|
|
29
|
+
- name: Ruff lint
|
|
30
|
+
run: ruff check .
|
|
31
|
+
|
|
32
|
+
- name: Ruff format check
|
|
33
|
+
run: ruff format --check .
|
|
34
|
+
|
|
35
|
+
- name: Mypy
|
|
36
|
+
run: mypy tutti_scraper.py
|
|
37
|
+
|
|
38
|
+
- name: Unit tests (no network, e2e excluded)
|
|
39
|
+
run: pytest
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: E2E (live API)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
# Every Monday at 06:00 UTC. Keeps this off the main CI path (real
|
|
6
|
+
# network calls against tutti.ch shouldn't run on every push) while
|
|
7
|
+
# still giving an early warning if tutti.ch changes their API shape.
|
|
8
|
+
- cron: "0 6 * * 1"
|
|
9
|
+
workflow_dispatch: {}
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
e2e:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install --upgrade pip
|
|
25
|
+
pip install "requests~=2.34" "pytest~=9.1" "pytest-cov~=7.1" "responses~=0.26"
|
|
26
|
+
|
|
27
|
+
- name: End-to-end tests against the live API
|
|
28
|
+
run: pytest -m e2e --no-cov
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
workflow_dispatch: {}
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Set up Python
|
|
16
|
+
uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
|
|
20
|
+
- name: Verify __version__ matches the pushed tag
|
|
21
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
22
|
+
run: |
|
|
23
|
+
python - <<'EOF'
|
|
24
|
+
import re
|
|
25
|
+
import sys
|
|
26
|
+
|
|
27
|
+
tag = "${{ github.ref_name }}".lstrip("v")
|
|
28
|
+
# A dry-run pre-release tag (e.g. v0.1.0-rc1) is expected to match
|
|
29
|
+
# __version__ on its base version only - the "-rc1" suffix is just
|
|
30
|
+
# a marker to route it through TestPyPI, not a real version bump.
|
|
31
|
+
base_version = tag.split("-", 1)[0]
|
|
32
|
+
content = open("tutti_scraper.py").read()
|
|
33
|
+
match = re.search(r'__version__\s*=\s*"([^"]+)"', content)
|
|
34
|
+
version = match.group(1) if match else None
|
|
35
|
+
|
|
36
|
+
print(f"tag={tag!r} base_version={base_version!r} __version__={version!r}")
|
|
37
|
+
if version != base_version:
|
|
38
|
+
print("::error::__version__ does not match the pushed tag - fix before releasing")
|
|
39
|
+
sys.exit(1)
|
|
40
|
+
EOF
|
|
41
|
+
|
|
42
|
+
- name: Install build tooling
|
|
43
|
+
run: python -m pip install --upgrade pip build
|
|
44
|
+
|
|
45
|
+
- name: Build sdist and wheel
|
|
46
|
+
run: python -m build
|
|
47
|
+
|
|
48
|
+
- name: Upload build artifacts
|
|
49
|
+
uses: actions/upload-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: dist
|
|
52
|
+
path: dist/
|
|
53
|
+
|
|
54
|
+
publish-testpypi:
|
|
55
|
+
needs: build
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
environment: testpypi
|
|
58
|
+
permissions:
|
|
59
|
+
id-token: write # required for PyPI Trusted Publishing (OIDC) - no token stored anywhere
|
|
60
|
+
steps:
|
|
61
|
+
- name: Download build artifacts
|
|
62
|
+
uses: actions/download-artifact@v4
|
|
63
|
+
with:
|
|
64
|
+
name: dist
|
|
65
|
+
path: dist/
|
|
66
|
+
|
|
67
|
+
- name: Publish to TestPyPI
|
|
68
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
69
|
+
with:
|
|
70
|
+
repository-url: https://test.pypi.org/legacy/
|
|
71
|
+
|
|
72
|
+
publish-pypi:
|
|
73
|
+
needs: publish-testpypi
|
|
74
|
+
# Only ever publish to real PyPI for an actual vX.Y.Z tag push (never for
|
|
75
|
+
# a manual workflow_dispatch run, and never for a pre-release-suffixed
|
|
76
|
+
# tag like v0.1.0-rc1 used to dry-run this workflow).
|
|
77
|
+
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-')
|
|
78
|
+
runs-on: ubuntu-latest
|
|
79
|
+
environment: pypi
|
|
80
|
+
permissions:
|
|
81
|
+
id-token: write
|
|
82
|
+
steps:
|
|
83
|
+
- name: Download build artifacts
|
|
84
|
+
uses: actions/download-artifact@v4
|
|
85
|
+
with:
|
|
86
|
+
name: dist
|
|
87
|
+
path: dist/
|
|
88
|
+
|
|
89
|
+
- name: Publish to PyPI
|
|
90
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-07-05
|
|
9
|
+
|
|
10
|
+
Initial release.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Scraper for tutti.ch listings, usable both as a CLI
|
|
15
|
+
(`tutti-scraper` / `python tutti_scraper.py`) and as a library
|
|
16
|
+
(`from tutti_scraper import scrape`).
|
|
17
|
+
- Search by any free-text phrase against tutti.ch's own GraphQL API
|
|
18
|
+
(reverse-engineered from its compiled JS bundles, not a published
|
|
19
|
+
schema).
|
|
20
|
+
- Recursive category/price-range partitioning that works around the
|
|
21
|
+
API's ~3000-offset pagination cap, so result sets far larger than one
|
|
22
|
+
page can still be fully covered; listings are de-duplicated by ID
|
|
23
|
+
across every slice.
|
|
24
|
+
- Full-detail mode (default): visits every matching listing individually
|
|
25
|
+
to extract GPS coordinates, full-resolution images, structured
|
|
26
|
+
attributes, and richer seller info, generically flattened for CSV
|
|
27
|
+
output; `--no-detail`/`detail=False` for a faster summary-only pass.
|
|
28
|
+
- Every listing's raw JSON and flattened CSV row both carry a direct
|
|
29
|
+
`url` back to the original ad.
|
|
30
|
+
- `lang` parameter (default `"de"`) for `"fr"`/`"it"` tutti.ch locales.
|
|
31
|
+
- `ScrapeResult` dataclass return value (`.rows`, `.listings`,
|
|
32
|
+
`.to_csv()`, `.to_json()`) for library use, with the CLI as a thin
|
|
33
|
+
wrapper around the same `scrape()` function.
|
|
34
|
+
- Console script entry point (`tutti-scraper`) and `pip install` support
|
|
35
|
+
via `pyproject.toml` packaging metadata; `--version` flag.
|
|
36
|
+
- Logging-based output (`-v`/`--verbose`, `-q`/`--quiet`) instead of bare
|
|
37
|
+
`print()`, so library consumers can configure/suppress it via the
|
|
38
|
+
standard `logging` module.
|
|
39
|
+
- Full type hints throughout, checked with mypy; linted and formatted
|
|
40
|
+
with Ruff.
|
|
41
|
+
- Unit test suite (100% coverage, all HTTP mocked) plus a smaller
|
|
42
|
+
end-to-end suite against the real live API, run on a separate weekly
|
|
43
|
+
GitHub Actions schedule.
|
|
44
|
+
- CI (GitHub Actions) running lint, type-check, and the unit suite on
|
|
45
|
+
every push/PR across Python 3.11 and 3.12.
|
|
46
|
+
- MIT license with an explicit statement welcoming AI agents/bots to use
|
|
47
|
+
the project under the same terms as a human developer.
|
|
48
|
+
- Project governance docs: `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`,
|
|
49
|
+
`SECURITY.md`, issue/PR templates.
|
|
50
|
+
- Deliberately interchangeable in shape with the sibling
|
|
51
|
+
[`autoscout24-scraper`](https://github.com/danyk20/autoscout24-scraper)
|
|
52
|
+
project: same `scrape()`/`ScrapeResult`/CLI/logging pattern, adapted to
|
|
53
|
+
tutti.ch's free-text search and GraphQL API instead of AutoScout24's
|
|
54
|
+
make/model REST API.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and maintainers pledge to make participation in
|
|
6
|
+
this project a harassment-free experience for everyone, regardless of age,
|
|
7
|
+
body size, visible or invisible disability, ethnicity, sex characteristics,
|
|
8
|
+
gender identity and expression, level of experience, education,
|
|
9
|
+
socio-economic status, nationality, personal appearance, race, religion, or
|
|
10
|
+
sexual identity and orientation. This applies equally to human contributors
|
|
11
|
+
and to AI agents/bots acting on someone's behalf.
|
|
12
|
+
|
|
13
|
+
## Our Standards
|
|
14
|
+
|
|
15
|
+
Examples of behavior that contributes to a positive environment:
|
|
16
|
+
|
|
17
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
18
|
+
- Giving and gracefully accepting constructive feedback
|
|
19
|
+
- Focusing on what is best for the community
|
|
20
|
+
|
|
21
|
+
Examples of unacceptable behavior:
|
|
22
|
+
|
|
23
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
24
|
+
- Public or private harassment
|
|
25
|
+
- Publishing others' private information without explicit permission
|
|
26
|
+
|
|
27
|
+
## Enforcement
|
|
28
|
+
|
|
29
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
30
|
+
reported to report@danielkosc.eu. All complaints will be reviewed and
|
|
31
|
+
investigated promptly and fairly.
|
|
32
|
+
|
|
33
|
+
## Attribution
|
|
34
|
+
|
|
35
|
+
This Code of Conduct is adapted from the
|
|
36
|
+
[Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for considering a contribution — human or AI agent, both welcome (see
|
|
4
|
+
the [License](README.md#license) section of the README).
|
|
5
|
+
|
|
6
|
+
## Dev setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/danyk20/tutti-scraper.git
|
|
10
|
+
cd tutti-scraper
|
|
11
|
+
pipenv install --dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Before opening a PR
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pipenv run ruff check . # lint
|
|
18
|
+
pipenv run ruff format . # format
|
|
19
|
+
pipenv run mypy tutti_scraper.py # type-check
|
|
20
|
+
pipenv run pytest # unit tests, must stay at 100% coverage
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If your change touches request/response handling against the real API,
|
|
24
|
+
also run the end-to-end suite (real network calls, ~10s):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pipenv run pytest -m e2e --no-cov
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Expectations
|
|
31
|
+
|
|
32
|
+
- **Every behavior change needs a test.** The unit suite mocks all HTTP
|
|
33
|
+
(via `responses`) and enforces 100% coverage — a change without a test
|
|
34
|
+
will fail CI on that basis alone.
|
|
35
|
+
- **Keep `verbose`/logging output backward compatible** unless the PR is
|
|
36
|
+
specifically about changing it — other code (and the e2e/CLI tests)
|
|
37
|
+
depends on the current message wording.
|
|
38
|
+
- If tutti.ch changes its GraphQL schema, required headers, or pagination
|
|
39
|
+
behavior, prefer fixing the affected function directly over adding a
|
|
40
|
+
workaround — the module docstring in `tutti_scraper.py` documents the
|
|
41
|
+
current API shape, and it was reverse-engineered from tutti.ch's own
|
|
42
|
+
compiled JS bundles rather than any published schema.
|
|
43
|
+
- Keep the change minimal and focused; this is a small single-file utility
|
|
44
|
+
by design (see the README's [Notes](README.md#notes) section for what's
|
|
45
|
+
intentionally out of scope, e.g. concurrency, Docker, a database layer).
|
|
46
|
+
- This project aims to stay interchangeable in shape with its sibling
|
|
47
|
+
[`autoscout24-scraper`](https://github.com/danyk20/autoscout24-scraper)
|
|
48
|
+
(same `scrape()`/`ScrapeResult`/CLI pattern, different data source) —
|
|
49
|
+
when both projects have an equivalent concept, prefer matching its name
|
|
50
|
+
and behavior over inventing a new one, unless tutti.ch's domain genuinely
|
|
51
|
+
requires something different.
|
|
52
|
+
|
|
53
|
+
## Questions / bug reports
|
|
54
|
+
|
|
55
|
+
Open a GitHub issue using the bug report template — include the exact
|
|
56
|
+
command you ran and, if relevant, the raw API response you got back.
|
|
57
|
+
|
|
58
|
+
## Releasing (maintainer only)
|
|
59
|
+
|
|
60
|
+
Publishing to PyPI is automated via `.github/workflows/release.yml` using
|
|
61
|
+
PyPI Trusted Publishing (no API tokens stored anywhere) — pushing a tag is
|
|
62
|
+
the only manual step:
|
|
63
|
+
|
|
64
|
+
1. Bump `__version__` in `tutti_scraper.py`.
|
|
65
|
+
2. Add a new entry at the top of `CHANGELOG.md` (Keep a Changelog format).
|
|
66
|
+
3. Commit those two changes, then tag and push:
|
|
67
|
+
```bash
|
|
68
|
+
git commit -am "Release vX.Y.Z"
|
|
69
|
+
git tag vX.Y.Z
|
|
70
|
+
git push origin master
|
|
71
|
+
git push origin vX.Y.Z
|
|
72
|
+
```
|
|
73
|
+
4. The release workflow verifies `__version__` matches the tag (fails fast
|
|
74
|
+
if they disagree), builds, publishes to TestPyPI, then to real PyPI.
|
|
75
|
+
Watch the Actions tab.
|
|
76
|
+
5. To dry-run the pipeline without a real release, push a pre-release tag
|
|
77
|
+
instead (e.g. `vX.Y.Z-rc1`) — it publishes to TestPyPI only and never
|
|
78
|
+
reaches real PyPI, since the version/tag check and the real-PyPI job
|
|
79
|
+
both key off an exact `vX.Y.Z` tag.
|
|
80
|
+
|
|
81
|
+
One-time setup this depends on (not done yet for this repo — see the
|
|
82
|
+
release workflow's own notes): a Trusted Publisher registered on both
|
|
83
|
+
pypi.org and test.pypi.org for this repo, and matching GitHub Environments
|
|
84
|
+
named `pypi`/`testpypi`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel Košč
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person or automated
|
|
6
|
+
agent (including AI assistants, bots, and other software acting on behalf
|
|
7
|
+
of a person) obtaining a copy of this software and associated documentation
|
|
8
|
+
files (the "Software"), to deal in the Software without restriction,
|
|
9
|
+
including without limitation the rights to use, copy, modify, merge,
|
|
10
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to the
|
|
12
|
+
following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
23
|
+
DEALINGS IN THE SOFTWARE.
|