autouncle-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.
- autouncle_scraper-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
- autouncle_scraper-0.1.0/.github/workflows/ci.yml +40 -0
- autouncle_scraper-0.1.0/.github/workflows/e2e.yml +30 -0
- autouncle_scraper-0.1.0/.github/workflows/release.yml +90 -0
- autouncle_scraper-0.1.0/.gitignore +19 -0
- autouncle_scraper-0.1.0/CHANGELOG.md +58 -0
- autouncle_scraper-0.1.0/CODE_OF_CONDUCT.md +36 -0
- autouncle_scraper-0.1.0/CONTRIBUTING.md +106 -0
- autouncle_scraper-0.1.0/LICENSE +21 -0
- autouncle_scraper-0.1.0/PKG-INFO +203 -0
- autouncle_scraper-0.1.0/PULL_REQUEST_TEMPLATE.md +13 -0
- autouncle_scraper-0.1.0/Pipfile +22 -0
- autouncle_scraper-0.1.0/Pipfile.lock +985 -0
- autouncle_scraper-0.1.0/README.md +168 -0
- autouncle_scraper-0.1.0/SECURITY.md +25 -0
- autouncle_scraper-0.1.0/autouncle_scraper.py +1424 -0
- autouncle_scraper-0.1.0/docs/REFERENCE.md +290 -0
- autouncle_scraper-0.1.0/pyproject.toml +86 -0
- autouncle_scraper-0.1.0/tests/conftest.py +38 -0
- autouncle_scraper-0.1.0/tests/fixtures/car_search_form_config.json +2565 -0
- autouncle_scraper-0.1.0/tests/fixtures/detail_6690428.html +2 -0
- autouncle_scraper-0.1.0/tests/fixtures/rsc_vw_golf8_mp30000_minyear2022_page1.txt +37 -0
- autouncle_scraper-0.1.0/tests/fixtures/rsc_vw_golf8_mp30000_minyear2022_page2.txt +34 -0
- autouncle_scraper-0.1.0/tests/fixtures/rsc_vw_golf8_multi_query_only.txt +47 -0
- autouncle_scraper-0.1.0/tests/fixtures/rsc_vw_golf_mp5000_page1.txt +3 -0
- autouncle_scraper-0.1.0/tests/fixtures/search_vw_golf_alltrack_page1.html +1 -0
- autouncle_scraper-0.1.0/tests/fixtures/search_vw_golf_alltrack_page2.html +1 -0
- autouncle_scraper-0.1.0/tests/test_cli.py +213 -0
- autouncle_scraper-0.1.0/tests/test_detail.py +228 -0
- autouncle_scraper-0.1.0/tests/test_e2e.py +107 -0
- autouncle_scraper-0.1.0/tests/test_filter.py +247 -0
- autouncle_scraper-0.1.0/tests/test_flatten.py +135 -0
- autouncle_scraper-0.1.0/tests/test_http.py +121 -0
- autouncle_scraper-0.1.0/tests/test_io.py +120 -0
- autouncle_scraper-0.1.0/tests/test_resolve.py +86 -0
- autouncle_scraper-0.1.0/tests/test_scrape.py +175 -0
- autouncle_scraper-0.1.0/tests/test_search.py +191 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something isn't working
|
|
4
|
+
title: ""
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: ""
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
**Command or code**
|
|
10
|
+
The exact CLI command or Python snippet that triggered the issue.
|
|
11
|
+
|
|
12
|
+
**Expected behavior**
|
|
13
|
+
What you expected to happen.
|
|
14
|
+
|
|
15
|
+
**Actual behavior**
|
|
16
|
+
What happened instead - include the full error/traceback if there is one.
|
|
17
|
+
|
|
18
|
+
**Environment**
|
|
19
|
+
- `autouncle-scraper` version (`autouncle-scraper --version` or `autouncle_scraper.__version__`):
|
|
20
|
+
- Python version:
|
|
21
|
+
- OS:
|
|
22
|
+
|
|
23
|
+
**Additional context**
|
|
24
|
+
If relevant, the raw response body you got back from AutoUncle (search page HTML,
|
|
25
|
+
detail page HTML, or GraphQL response) - especially useful for anything that looks
|
|
26
|
+
like a markup/API shape change on AutoUncle's end, since several parts of this
|
|
27
|
+
scraper (see docs/REFERENCE.md's "maintenance risk" section) are only as stable
|
|
28
|
+
as AutoUncle's own frontend markup.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
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.13"]
|
|
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" "beautifulsoup4~=4.12" \
|
|
27
|
+
"pytest~=9.1" "pytest-cov~=7.1" "responses~=0.26" \
|
|
28
|
+
"ruff~=0.15" "mypy~=2.1" "types-requests~=2.33" "types-beautifulsoup4~=4.12"
|
|
29
|
+
|
|
30
|
+
- name: Ruff lint
|
|
31
|
+
run: ruff check .
|
|
32
|
+
|
|
33
|
+
- name: Ruff format check
|
|
34
|
+
run: ruff format --check .
|
|
35
|
+
|
|
36
|
+
- name: Mypy
|
|
37
|
+
run: mypy autouncle_scraper.py
|
|
38
|
+
|
|
39
|
+
- name: Unit tests (no network, e2e excluded)
|
|
40
|
+
run: pytest
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: E2E
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch: {}
|
|
5
|
+
schedule:
|
|
6
|
+
# Weekly, Monday 06:00 UTC - catches drift between AutoUncle's live
|
|
7
|
+
# markup/API shape and this scraper's fixtures/regexes early, without
|
|
8
|
+
# gating every PR on the live site's availability.
|
|
9
|
+
- cron: "0 6 * * 1"
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
e2e:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
continue-on-error: true # live-site scraping is inherently flaky; never block merges on it
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.13"
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
pip install "requests~=2.34" "beautifulsoup4~=4.12" \
|
|
27
|
+
"pytest~=9.1" "pytest-cov~=7.1" "responses~=0.26"
|
|
28
|
+
|
|
29
|
+
- name: End-to-end tests against the live site
|
|
30
|
+
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.13"
|
|
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("autouncle_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,58 @@
|
|
|
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
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-07-21
|
|
11
|
+
|
|
12
|
+
Initial release.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Scraper for autouncle.ch used-car listings, usable both as a CLI
|
|
17
|
+
(`autouncle-scraper` / `python autouncle_scraper.py`) and as a library
|
|
18
|
+
(`from autouncle_scraper import scrape`) with the same call shape as the
|
|
19
|
+
[AutoScout24 scraper](https://github.com/danyk20/autoscout24-scraper) this
|
|
20
|
+
project is a drop-in-compatible sibling of.
|
|
21
|
+
- Search by any brand/model (resolved dynamically against AutoUncle's own
|
|
22
|
+
`/api/v4/car_search_form/config` endpoint, not a hardcoded list), with
|
|
23
|
+
optional price/mileage/first-registration-year range filters.
|
|
24
|
+
- Two independent search mechanisms, chosen automatically: schema.org
|
|
25
|
+
JSON-LD pagination for unfiltered searches (the richest, most stable
|
|
26
|
+
source), and a reverse-engineered GraphQL + Next.js RSC mechanism for
|
|
27
|
+
filtered searches (AutoUncle suppresses JSON-LD on any filtered page).
|
|
28
|
+
- Full-detail mode (default): visits every matching listing individually to
|
|
29
|
+
extract every field its detail page exposes - full address, AutoUncle's
|
|
30
|
+
own price-rating/market-analysis labels, a complete price-history time
|
|
31
|
+
series (a field AutoScout24 doesn't expose at all), full image gallery,
|
|
32
|
+
and an equipment/spec breakdown - generically flattened for CSV output.
|
|
33
|
+
`--no-detail`/`detail=False` for a faster, summary-only pass on
|
|
34
|
+
unfiltered searches.
|
|
35
|
+
- Every listing's raw JSON and flattened CSV row both carry a direct `url`
|
|
36
|
+
back to the original ad.
|
|
37
|
+
- `domain` parameter (default `"ch"`) so the API host/locale/URL segment
|
|
38
|
+
aren't hardcoded to Switzerland, in case another AutoUncle country site is
|
|
39
|
+
wired up in the future.
|
|
40
|
+
- `ScrapeResult` dataclass return value (`.rows`, `.listings`, `.to_csv()`,
|
|
41
|
+
`.to_json()`) for library use, with the CLI as a thin wrapper around the
|
|
42
|
+
same `scrape()` function.
|
|
43
|
+
- Console script entry point (`autouncle-scraper`) and `pip install` support
|
|
44
|
+
via `pyproject.toml` packaging metadata; `--version` flag.
|
|
45
|
+
- Logging-based output (`-v`/`--verbose`, `-q`/`--quiet`) instead of bare
|
|
46
|
+
`print()`, so library consumers can configure/suppress it via the
|
|
47
|
+
standard `logging` module.
|
|
48
|
+
- Full type hints throughout, checked with mypy; linted and formatted with
|
|
49
|
+
Ruff.
|
|
50
|
+
- Unit test suite (100% coverage, all HTTP mocked, all fixtures real
|
|
51
|
+
captures from the live site) plus a smaller end-to-end suite against the
|
|
52
|
+
real live site, run on a separate weekly GitHub Actions schedule.
|
|
53
|
+
- CI (GitHub Actions) running lint, type-check, and the unit suite on every
|
|
54
|
+
push/PR against Python 3.13.
|
|
55
|
+
- MIT license with an explicit statement welcoming AI agents/bots to use the
|
|
56
|
+
project under the same terms as a human developer.
|
|
57
|
+
- Project governance docs: `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`,
|
|
58
|
+
`SECURITY.md`, issue/PR templates, `docs/REFERENCE.md`.
|
|
@@ -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 maintainer@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,106 @@
|
|
|
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/autouncle-scraper.git
|
|
10
|
+
cd autouncle-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 autouncle_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 site, also
|
|
24
|
+
run the end-to-end suite (real network calls, a few seconds):
|
|
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 (via
|
|
33
|
+
`responses`) and enforces 100% coverage — a change without a test will
|
|
34
|
+
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 AutoUncle changes its markup or API shape, prefer fixing the affected
|
|
39
|
+
function directly over adding a workaround — the module docstring in
|
|
40
|
+
`autouncle_scraper.py` documents the current mechanisms, and
|
|
41
|
+
`docs/REFERENCE.md`'s "maintenance risk" section lists exactly which bits
|
|
42
|
+
are most likely to need attention first.
|
|
43
|
+
- Keep the change minimal and focused; this is a small single-file utility
|
|
44
|
+
by design, same as the AutoScout24 scraper it mirrors.
|
|
45
|
+
|
|
46
|
+
## If the site's markup changes
|
|
47
|
+
|
|
48
|
+
Several parts of this scraper (the RSC listing-id regex, the BeautifulSoup
|
|
49
|
+
equipment/gallery selectors, the exact `CarSearchInput` GraphQL field list)
|
|
50
|
+
were derived empirically by watching what AutoUncle's own frontend does,
|
|
51
|
+
not from any published API contract — so they can break if AutoUncle ships
|
|
52
|
+
a redesign. To re-derive them:
|
|
53
|
+
|
|
54
|
+
1. Open the relevant page in a real browser (search page with the filter
|
|
55
|
+
form, or a detail page).
|
|
56
|
+
2. Monkey-patch `window.fetch` before interacting, so you can see exactly
|
|
57
|
+
what the page's own JavaScript sends and receives:
|
|
58
|
+
```js
|
|
59
|
+
const _f = window.fetch;
|
|
60
|
+
window.fetch = function(...args) {
|
|
61
|
+
console.log('FETCH', args[0], args[1] && args[1].body);
|
|
62
|
+
return _f.apply(this, args);
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
3. Toggle **one** filter control at a time (price, then km, then year, ...)
|
|
66
|
+
and read the logged GraphQL request body to (re)learn field names.
|
|
67
|
+
4. For the RSC listing-id pattern: fetch a search URL with header
|
|
68
|
+
`{"RSC": "1"}`, save the raw response text, and diff a few different
|
|
69
|
+
real captures (different brand/model/filter combinations) before
|
|
70
|
+
changing the regex — see `tests/fixtures/rsc_*.txt` for the shape these
|
|
71
|
+
should take.
|
|
72
|
+
5. For BeautifulSoup selectors: prefer stable `data-*` attributes or
|
|
73
|
+
structural shape (e.g. "an `<li>` with exactly two `<span>` children")
|
|
74
|
+
over CSS class names, which are build-hashed and change on every deploy.
|
|
75
|
+
|
|
76
|
+
## Questions / bug reports
|
|
77
|
+
|
|
78
|
+
Open a GitHub issue using the bug report template — include the exact
|
|
79
|
+
command you ran and, if relevant, the raw HTML/JSON response you got back.
|
|
80
|
+
|
|
81
|
+
## Releasing (maintainer only)
|
|
82
|
+
|
|
83
|
+
Publishing to PyPI is automated via `.github/workflows/release.yml` using
|
|
84
|
+
PyPI Trusted Publishing (no API tokens stored anywhere) — pushing a tag is
|
|
85
|
+
the only manual step. **This requires a one-time setup that hasn't been
|
|
86
|
+
done for this project yet**: a Trusted Publisher registered on both
|
|
87
|
+
pypi.org and test.pypi.org for this repository, and matching GitHub
|
|
88
|
+
Environments named `pypi`/`testpypi`. Until that's done, `release.yml` will
|
|
89
|
+
build successfully but fail at the publish step.
|
|
90
|
+
|
|
91
|
+
1. Bump `__version__` in `autouncle_scraper.py`.
|
|
92
|
+
2. Add a new entry at the top of `CHANGELOG.md` (Keep a Changelog format).
|
|
93
|
+
3. Commit those two changes, then tag and push:
|
|
94
|
+
```bash
|
|
95
|
+
git commit -am "Release vX.Y.Z"
|
|
96
|
+
git tag vX.Y.Z
|
|
97
|
+
git push origin main
|
|
98
|
+
git push origin vX.Y.Z
|
|
99
|
+
```
|
|
100
|
+
4. The release workflow verifies `__version__` matches the tag (fails fast
|
|
101
|
+
if they disagree), builds, publishes to TestPyPI, then to real PyPI.
|
|
102
|
+
Watch the Actions tab.
|
|
103
|
+
5. To dry-run the pipeline without a real release, push a pre-release tag
|
|
104
|
+
instead (e.g. `vX.Y.Z-rc1`) — it publishes to TestPyPI only and never
|
|
105
|
+
reaches real PyPI, since the version/tag check and the real-PyPI job
|
|
106
|
+
both key off an exact `vX.Y.Z` tag.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel Košč
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autouncle-scraper
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Free, keyless scraper and library for autouncle.ch used-car listings. Unofficial, not affiliated with AutoUncle ApS.
|
|
5
|
+
Project-URL: Homepage, https://github.com/danyk20/autouncle-scraper
|
|
6
|
+
Project-URL: Repository, https://github.com/danyk20/autouncle-scraper
|
|
7
|
+
Project-URL: Issues, https://github.com/danyk20/autouncle-scraper/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/danyk20/autouncle-scraper/blob/master/CHANGELOG.md
|
|
9
|
+
Author-email: Daniel Košč <maintainer@danielkosc.eu>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: autouncle,cars,cli,scraper,switzerland,web-scraping
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.13
|
|
24
|
+
Requires-Dist: beautifulsoup4~=4.12
|
|
25
|
+
Requires-Dist: requests~=2.34
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: mypy~=2.1; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov~=7.1; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest~=9.1; extra == 'dev'
|
|
30
|
+
Requires-Dist: responses~=0.26; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff~=0.15; extra == 'dev'
|
|
32
|
+
Requires-Dist: types-beautifulsoup4~=4.12; extra == 'dev'
|
|
33
|
+
Requires-Dist: types-requests~=2.33; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# AutoUncle Scraper
|
|
37
|
+
|
|
38
|
+
[](https://github.com/danyk20/autouncle-scraper/actions/workflows/ci.yml)
|
|
39
|
+
[](https://pypi.org/project/autouncle-scraper/)
|
|
40
|
+
[](#testing)
|
|
41
|
+
[](LICENSE)
|
|
42
|
+
[](https://www.python.org/)
|
|
43
|
+
|
|
44
|
+
> Unofficial, independently developed project — not affiliated with, endorsed by, or sponsored by AutoUncle ApS. "AutoUncle" is a trademark of its respective owner.
|
|
45
|
+
|
|
46
|
+
Fetches every listing for a given brand/model from AutoUncle — for free, no
|
|
47
|
+
API key, no paid scraping service. It's a drop-in-compatible sibling of the
|
|
48
|
+
[AutoScout24 scraper](https://github.com/danyk20/autoscout24-scraper): same
|
|
49
|
+
`scrape()` call shape, same `ScrapeResult` return type, same CLI flags, same
|
|
50
|
+
MIT license and tooling — switch `from autoscout24_scraper import scrape` to
|
|
51
|
+
`from autouncle_scraper import scrape` and the rest of your code doesn't
|
|
52
|
+
need to change.
|
|
53
|
+
|
|
54
|
+
Under the hood the two projects work differently, because the two sites do:
|
|
55
|
+
AutoScout24 exposes one clean JSON API; AutoUncle is a Next.js site with no
|
|
56
|
+
such API, so this scraper reads the same structured data (schema.org
|
|
57
|
+
JSON-LD) and, for filtered searches, the same internal data mechanism
|
|
58
|
+
(GraphQL + React Server Components) AutoUncle's own frontend uses — all
|
|
59
|
+
reverse-engineered by observing real traffic, documented in full in the
|
|
60
|
+
module docstring and [docs/REFERENCE.md](docs/REFERENCE.md).
|
|
61
|
+
|
|
62
|
+
**A stronger legal footing than most scrapers.** AutoUncle's own detail
|
|
63
|
+
pages explicitly mark their listing data as a `Dataset` with
|
|
64
|
+
`"isAccessibleForFree": true`, licensed
|
|
65
|
+
[**CC BY 4.0**](https://creativecommons.org/licenses/by/4.0/). That's not
|
|
66
|
+
just "we call their own frontend's endpoint" reasoning (though that's true
|
|
67
|
+
too, same as AutoScout24) — it's AutoUncle's own explicit declaration that
|
|
68
|
+
this data is meant to be freely reused, with attribution.
|
|
69
|
+
|
|
70
|
+
**🤖 Robot-friendly.** This project is explicitly intended to be run, read,
|
|
71
|
+
imported, or adapted by AI agents and bots, same as a human developer — see
|
|
72
|
+
[License](#license).
|
|
73
|
+
|
|
74
|
+
## Setup
|
|
75
|
+
|
|
76
|
+
Requires [pipenv](https://pipenv.pypa.io/) (`brew install pipenv`).
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/danyk20/autouncle-scraper.git
|
|
80
|
+
cd autouncle-scraper
|
|
81
|
+
pipenv install --dev
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Contributing, linting, and testing commands: see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
85
|
+
|
|
86
|
+
## Usage
|
|
87
|
+
|
|
88
|
+
### CLI
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pipenv run python autouncle_scraper.py --make VW --model Golf
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Prints progress, then writes `vw_golf.csv` and `vw_golf.json` in the current
|
|
95
|
+
directory. Installed via `pip install` instead? Drop `pipenv run` — the same
|
|
96
|
+
command is `autouncle-scraper --make VW --model Golf`.
|
|
97
|
+
|
|
98
|
+
| Flag | Description |
|
|
99
|
+
|---|---|
|
|
100
|
+
| `--version` | Print the installed version and exit |
|
|
101
|
+
| `--make` | Brand name, e.g. `VW` (required) |
|
|
102
|
+
| `--model` | Model name, e.g. `Golf` (required) |
|
|
103
|
+
| `--domain` | Country domain (default `ch`) — only `ch` is implemented today, see [docs/REFERENCE.md](docs/REFERENCE.md#domains) |
|
|
104
|
+
| `--category` | `car` (default) — the only category implemented |
|
|
105
|
+
| `--out` | Output file base name, without extension. Defaults to `<make>_<model>` |
|
|
106
|
+
| `--no-detail` | Skip per-listing detail visits (unfiltered searches only — see below) |
|
|
107
|
+
| `--delay` | Seconds between requests (default `0.4`) — raise this if you get rate-limited |
|
|
108
|
+
| `--price-from` / `--price-to` | Filter by price in CHF (inclusive, either end optional) |
|
|
109
|
+
| `--mileage-from` / `--mileage-to` | Filter by mileage in km (inclusive, either end optional) |
|
|
110
|
+
| `--year-from` / `--year-to` | Filter by first-registration year (inclusive, either end optional) |
|
|
111
|
+
| `-v` / `--verbose` | Also show debug-level detail, including every HTTP request (mutually exclusive with `-q`) |
|
|
112
|
+
| `-q` / `--quiet` | Suppress progress output; only warnings/errors (mutually exclusive with `-v`) |
|
|
113
|
+
|
|
114
|
+
Filters combine with AND and are applied server-side. A mistyped make/model
|
|
115
|
+
prints a clean error (plus, for an unknown model, the list of valid models)
|
|
116
|
+
instead of crashing.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Fast mode: search results only, skip per-listing detail
|
|
120
|
+
pipenv run python autouncle_scraper.py --make VW --model Golf --no-detail
|
|
121
|
+
|
|
122
|
+
# 2015 or newer, under CHF 30'000
|
|
123
|
+
pipenv run python autouncle_scraper.py --make VW --model "Golf VIII" --price-to 30000 --year-from 2015
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**One honest asymmetry vs. AutoScout24**: unfiltered searches use
|
|
127
|
+
schema.org JSON-LD, which is already fairly rich even without `--no-detail`.
|
|
128
|
+
Filtered searches use a different mechanism (see
|
|
129
|
+
[docs/REFERENCE.md](docs/REFERENCE.md)) that carries *only* listing ids —
|
|
130
|
+
so `--no-detail` on a filtered search gives you ids only, plus a logged
|
|
131
|
+
warning. Leave `--no-detail` off (the default) for anything beyond a bare
|
|
132
|
+
count.
|
|
133
|
+
|
|
134
|
+
### As a library
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pip install autouncle-scraper
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from autouncle_scraper import scrape
|
|
142
|
+
|
|
143
|
+
result = scrape("VW", "Golf", price_to=30000, year_from=2015)
|
|
144
|
+
|
|
145
|
+
for row in result.rows: # list[dict], CSV-ready
|
|
146
|
+
print(row["price"], row["mileageKm"], row["url"])
|
|
147
|
+
|
|
148
|
+
result.to_csv("vw_golf.csv") # optional — no files are written unless you ask
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Full `scrape()` signature, the `ScrapeResult` return type, and the complete
|
|
152
|
+
JSON/CSV field schema — including price history, gallery, and equipment
|
|
153
|
+
fields AutoScout24 doesn't have — **[docs/REFERENCE.md](docs/REFERENCE.md)**.
|
|
154
|
+
|
|
155
|
+
## Testing
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pipenv run pytest # unit tests (fast, no network), 100% coverage
|
|
159
|
+
pipenv run pytest -m e2e --no-cov # end-to-end tests against the real live site
|
|
160
|
+
pipenv run pytest -m "e2e or not e2e" --no-cov # everything
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Unit tests mock all HTTP (via [`responses`](https://github.com/getsentry/responses))
|
|
164
|
+
against fixtures that are real captures from the live site, and cover 100%
|
|
165
|
+
of `autouncle_scraper.py`. E2E tests target a narrow, low-volume model (VW
|
|
166
|
+
Golf Alltrack) to confirm the scraper still works against the live site
|
|
167
|
+
without putting real load on it. Coverage detail by area:
|
|
168
|
+
[docs/REFERENCE.md](docs/REFERENCE.md#test-coverage-by-area).
|
|
169
|
+
|
|
170
|
+
## Contributing
|
|
171
|
+
|
|
172
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for dev setup, pre-PR checks, and
|
|
173
|
+
what to do if AutoUncle changes its markup.
|
|
174
|
+
|
|
175
|
+
Be a reasonable citizen: the default request delay is intentional — this
|
|
176
|
+
scrapes an undocumented data mechanism the site's own frontend uses, not a
|
|
177
|
+
public API with a stated rate limit. Don't remove the delay or crank up
|
|
178
|
+
concurrency.
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
Released under the [MIT License](LICENSE) — you can use, copy, modify,
|
|
183
|
+
merge, publish, distribute, and sell copies of this code, for free, for any
|
|
184
|
+
purpose, commercial or not, as long as the license text stays attached. No
|
|
185
|
+
warranty.
|
|
186
|
+
|
|
187
|
+
**AI agents, LLM-based coding assistants, and other bots are explicitly
|
|
188
|
+
welcome to use this project** — to run the scraper, read and parse its
|
|
189
|
+
output, import `scrape()` into another project, or read and adapt its
|
|
190
|
+
source — under exactly the same terms as a human, with no additional
|
|
191
|
+
restriction and no need to ask permission. That's why
|
|
192
|
+
[docs/REFERENCE.md](docs/REFERENCE.md) documents the full function
|
|
193
|
+
signature, return type, and data schema: so a bot can integrate correctly
|
|
194
|
+
without a human in the loop.
|
|
195
|
+
|
|
196
|
+
This license covers this project's own code. It does not, by itself, grant
|
|
197
|
+
any rights to AutoUncle's data beyond what AutoUncle itself has already
|
|
198
|
+
declared: its listing `Dataset` objects are explicitly marked
|
|
199
|
+
`"isAccessibleForFree": true` and licensed
|
|
200
|
+
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) — see
|
|
201
|
+
[docs/REFERENCE.md](docs/REFERENCE.md) for exactly where that declaration
|
|
202
|
+
lives. What you do with the scraped results is between you and AutoUncle's
|
|
203
|
+
terms of service.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## What & why
|
|
2
|
+
|
|
3
|
+
<!-- What does this change, and why? -->
|
|
4
|
+
|
|
5
|
+
## Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] `ruff check .` and `ruff format --check .` pass
|
|
8
|
+
- [ ] `mypy autouncle_scraper.py` passes
|
|
9
|
+
- [ ] `pytest` passes with coverage at or above the configured threshold
|
|
10
|
+
- [ ] New/changed behavior has a test (mocked via `responses`, not a real network call)
|
|
11
|
+
- [ ] If this touches request/response handling against the real site, `pytest -m e2e --no-cov` was run locally
|
|
12
|
+
- [ ] `docs/REFERENCE.md` updated if the public API, field schema, or a documented mechanism changed
|
|
13
|
+
- [ ] `CHANGELOG.md` has a new entry under `Unreleased`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[[source]]
|
|
2
|
+
url = "https://pypi.org/simple"
|
|
3
|
+
verify_ssl = true
|
|
4
|
+
name = "pypi"
|
|
5
|
+
|
|
6
|
+
[packages]
|
|
7
|
+
requests = "~=2.34"
|
|
8
|
+
beautifulsoup4 = "~=4.12"
|
|
9
|
+
|
|
10
|
+
[dev-packages]
|
|
11
|
+
pytest = "~=9.1"
|
|
12
|
+
pytest-cov = "~=7.1"
|
|
13
|
+
responses = "~=0.26"
|
|
14
|
+
ruff = "~=0.15"
|
|
15
|
+
mypy = "~=2.1"
|
|
16
|
+
types-requests = "~=2.33"
|
|
17
|
+
types-beautifulsoup4 = "~=4.12"
|
|
18
|
+
build = "~=1.5"
|
|
19
|
+
twine = "~=6.2"
|
|
20
|
+
|
|
21
|
+
[requires]
|
|
22
|
+
python_version = "3.13"
|