billiger-mcp 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.
- billiger_mcp-0.1.0/.github/workflows/publish.yml +20 -0
- billiger_mcp-0.1.0/.github/workflows/registry.yml +61 -0
- billiger_mcp-0.1.0/.github/workflows/smoke.yml +21 -0
- billiger_mcp-0.1.0/LICENSE +21 -0
- billiger_mcp-0.1.0/PKG-INFO +61 -0
- billiger_mcp-0.1.0/README-de.md +49 -0
- billiger_mcp-0.1.0/README-fa.md +49 -0
- billiger_mcp-0.1.0/README.md +49 -0
- billiger_mcp-0.1.0/pyproject.toml +25 -0
- billiger_mcp-0.1.0/server.json +1 -0
- billiger_mcp-0.1.0/src/billiger_mcp/__init__.py +7 -0
- billiger_mcp-0.1.0/src/billiger_mcp/domain.py +197 -0
- billiger_mcp-0.1.0/src/billiger_mcp/http.py +120 -0
- billiger_mcp-0.1.0/src/billiger_mcp/server.py +125 -0
- billiger_mcp-0.1.0/tests/__init__.py +0 -0
- billiger_mcp-0.1.0/tests/fixtures/home.html +13101 -0
- billiger_mcp-0.1.0/tests/fixtures/product-iphone17.html +11939 -0
- billiger_mcp-0.1.0/tests/fixtures/search-iphone.html +17312 -0
- billiger_mcp-0.1.0/tests/fixtures/search-nomatch.html +1379 -0
- billiger_mcp-0.1.0/tests/smoke_live.py +17 -0
- billiger_mcp-0.1.0/tests/test_domain.py +167 -0
- billiger_mcp-0.1.0/tests/test_live.py +53 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
id-token: write # required for PyPI trusted publishing (OIDC)
|
|
12
|
+
contents: read
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- run: pip install build
|
|
19
|
+
- run: python -m build
|
|
20
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Publish to MCP Registry
|
|
2
|
+
|
|
3
|
+
# Official MCP Registry (registry.modelcontextprotocol.io) via GitHub OIDC.
|
|
4
|
+
# No secret, no interactive login: the runner's OIDC token proves ownership
|
|
5
|
+
# of the io.github.mohammad-abbasi-sh/* namespace.
|
|
6
|
+
# Refs: https://github.com/modelcontextprotocol/registry
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
tags: ["v*"]
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
id-token: write # required for OIDC -> MCP Registry
|
|
18
|
+
contents: read
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Sync server.json version to tag
|
|
23
|
+
# Only sync when running on a version tag (v*). On workflow_dispatch
|
|
24
|
+
# (ref = refs/heads/main) keep the version committed in server.json.
|
|
25
|
+
run: |
|
|
26
|
+
VER=""
|
|
27
|
+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
|
28
|
+
TAG="${GITHUB_REF#refs/tags/}"
|
|
29
|
+
VER="${TAG#v}"
|
|
30
|
+
fi
|
|
31
|
+
if [ -n "$VER" ]; then
|
|
32
|
+
python3 - "$VER" << 'EOF'
|
|
33
|
+
import json, sys
|
|
34
|
+
ver = sys.argv[1]
|
|
35
|
+
d = json.load(open('server.json'))
|
|
36
|
+
d['version'] = ver
|
|
37
|
+
for pkg in d.get('packages', []):
|
|
38
|
+
pkg['version'] = ver
|
|
39
|
+
json.dump(d, open('server.json', 'w'), indent=2, ensure_ascii=False)
|
|
40
|
+
print('server.json version ->', ver)
|
|
41
|
+
EOF
|
|
42
|
+
else
|
|
43
|
+
echo "No version tag ($GITHUB_REF); keeping server.json version as-is"
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
- name: Install mcp-publisher
|
|
47
|
+
run: |
|
|
48
|
+
curl -sL "https://github.com/modelcontextprotocol/registry/releases/download/v1.8.7/mcp-publisher_linux_amd64.tar.gz" -o /tmp/mcp-publisher.tar.gz
|
|
49
|
+
tar -xzf /tmp/mcp-publisher.tar.gz -C /tmp
|
|
50
|
+
sudo mv /tmp/mcp-publisher /usr/local/bin/mcp-publisher
|
|
51
|
+
mcp-publisher --version
|
|
52
|
+
|
|
53
|
+
- name: Validate server.json
|
|
54
|
+
run: mcp-publisher validate server.json
|
|
55
|
+
|
|
56
|
+
- name: Publish to MCP Registry (OIDC)
|
|
57
|
+
run: |
|
|
58
|
+
mcp-publisher login github-oidc
|
|
59
|
+
mcp-publisher publish server.json
|
|
60
|
+
# A registry outage must never break the release; re-run from Actions if needed.
|
|
61
|
+
continue-on-error: true
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Daily live smoke
|
|
2
|
+
|
|
3
|
+
# One fixed probe per day: catches fingerprint rot / bot-wall changes
|
|
4
|
+
# before users hit them. Fails visibly on 403/timeout.
|
|
5
|
+
on:
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: "0 6 * * *"
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
smoke:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- name: Install
|
|
19
|
+
run: pip install -e .
|
|
20
|
+
- name: Smoke probe
|
|
21
|
+
run: python tests/smoke_live.py
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohammad Abbasi
|
|
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,61 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: billiger-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Unofficial read-only MCP server for billiger.de — German price comparison
|
|
5
|
+
Author: Mohammad Abbasi
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: httpx>=0.27
|
|
10
|
+
Requires-Dist: mcp<2
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# billiger-mcp 🛒
|
|
14
|
+
|
|
15
|
+
mcp-name: io.github.mohammad-abbasi-sh/billiger-mcp
|
|
16
|
+
|
|
17
|
+
Unofficial **read-only** MCP server for **[billiger.de](https://www.billiger.de)** — German price comparison from billiger.de (free, no key, no login): search products with best prices, compare shop offers, and today's deals. No key, no login.
|
|
18
|
+
|
|
19
|
+
> Built by Mohammad Abbasi as part of the "Germany MCP factory". Not affiliated with billiger.de.
|
|
20
|
+
|
|
21
|
+
## For AI agents
|
|
22
|
+
|
|
23
|
+
Add to your MCP client config (stdio):
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"mcpServers": {
|
|
28
|
+
"billiger": {
|
|
29
|
+
"command": "uvx",
|
|
30
|
+
"args": ["billiger-mcp==0.1.0"]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or run locally: `python -m billiger_mcp.server` (needs `mcp<2`, `httpx`).
|
|
37
|
+
|
|
38
|
+
## Tools
|
|
39
|
+
|
|
40
|
+
| Tool | Description |
|
|
41
|
+
|------|-------------|
|
|
42
|
+
| `billiger_search_prices` | Search billiger.de products by name: best price, offer count, rating — `query`, `limit` 1..20 |
|
|
43
|
+
| `billiger_product_offers` | Compare shop offers for one product (shop, price, shipping, total, delivery) — `product` (billiger.de URL, baseproducts id or slug), `limit` 1..20 |
|
|
44
|
+
| `billiger_best_deals` | Today's deals from the billiger.de home page: product, best price, offer count — `limit` 1..20 |
|
|
45
|
+
| `billiger_health` | Reachability probe (ok / blocked / error) — one polite request |
|
|
46
|
+
|
|
47
|
+
## Development
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python3 -m venv .venv && .venv/bin/pip install "mcp<2" httpx pytest
|
|
51
|
+
.venv/bin/pip install -e .
|
|
52
|
+
.venv/bin/python -m pytest tests/ -q
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
Built by [Mohammad Abbasi](https://github.com/mohammad-abbasi-sh) — [Almanibama](https://almanibama.ir) · [mabbasi.ir](https://mabbasi.ir)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# billiger-mcp 🛒
|
|
2
|
+
|
|
3
|
+
mcp-name: io.github.mohammad-abbasi-sh/billiger-mcp
|
|
4
|
+
|
|
5
|
+
Inoffizieller **nur lesender** MCP-Server für **[billiger.de](https://www.billiger.de)** — Deutscher Preisvergleich von billiger.de (kostenlos, kein Schlüssel, kein Login): Produkte mit Bestpreisen suchen, Shop-Angebote vergleichen und Tagesdeals. Kein Schlüssel, keine Anmeldung.
|
|
6
|
+
|
|
7
|
+
> Gebaut von Mohammad Abbasi als Teil der "Germany MCP factory". Nicht mit billiger.de verbunden.
|
|
8
|
+
|
|
9
|
+
## Für KI-Agenten
|
|
10
|
+
|
|
11
|
+
Zur MCP-Client-Konfiguration hinzufügen (stdio):
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"billiger": {
|
|
17
|
+
"command": "uvx",
|
|
18
|
+
"args": ["billiger-mcp==0.1.0"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Oder lokal starten: `python -m billiger_mcp.server` (benötigt `mcp<2`, `httpx`).
|
|
25
|
+
|
|
26
|
+
## Tools
|
|
27
|
+
|
|
28
|
+
| Tool | Beschreibung |
|
|
29
|
+
|------|-------------|
|
|
30
|
+
| `billiger_search_prices` | Produkte mit Bestpreisen suchen |
|
|
31
|
+
| `billiger_product_offers` | Shop-Angebote für ein Produkt vergleichen |
|
|
32
|
+
| `billiger_best_deals` | Tagesdeals von der Startseite |
|
|
33
|
+
| `billiger_health` | Erreichbarkeitsprüfung (ok / blocked / error) — eine höfliche Anfrage |
|
|
34
|
+
|
|
35
|
+
## Entwicklung
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python3 -m venv .venv && .venv/bin/pip install "mcp<2" httpx pytest
|
|
39
|
+
.venv/bin/pip install -e .
|
|
40
|
+
.venv/bin/python -m pytest tests/ -q
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Lizenz
|
|
44
|
+
|
|
45
|
+
MIT
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
Built by [Mohammad Abbasi](https://github.com/mohammad-abbasi-sh) — [Almanibama](https://almanibama.ir) · [mabbasi.ir](https://mabbasi.ir)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# billiger-mcp 🛒
|
|
2
|
+
|
|
3
|
+
mcp-name: io.github.mohammad-abbasi-sh/billiger-mcp
|
|
4
|
+
|
|
5
|
+
سرور MCP غیررسمی و **فقطخواندنی** برای **[billiger.de](https://www.billiger.de)** — مقایسهٔ قیمت آلمان از billiger.de (رایگان، بدون کلید): جستوجوی محصولات با بهترین قیمت، مقایسهٔ پیشنهادهای فروشگاهها و تخفیفهای روز. بدون کلید، بدون ورود.
|
|
6
|
+
|
|
7
|
+
> ساختهٔ محمد عباسی، بخشی از «کارخانهٔ MCP آلمان». وابسته به billiger.de نیست.
|
|
8
|
+
|
|
9
|
+
## برای ایجنتهای هوش مصنوعی
|
|
10
|
+
|
|
11
|
+
به پیکربندی MCP کلاینت اضافه کنید (stdio):
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"billiger": {
|
|
17
|
+
"command": "uvx",
|
|
18
|
+
"args": ["billiger-mcp==0.1.0"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
یا بهصورت محلی اجرا کنید: `python -m billiger_mcp.server` (نیازمند `mcp<2` و `httpx`).
|
|
25
|
+
|
|
26
|
+
## ابزارها
|
|
27
|
+
|
|
28
|
+
| ابزار | توضیح |
|
|
29
|
+
|------|-------|
|
|
30
|
+
| `billiger_search_prices` | جستوجوی محصولات با بهترین قیمت |
|
|
31
|
+
| `billiger_product_offers` | مقایسهٔ پیشنهادهای فروشگاهها برای یک محصول |
|
|
32
|
+
| `billiger_best_deals` | تخفیفهای روز از صفحهٔ اصلی |
|
|
33
|
+
| `billiger_health` | بررسی دسترسپذیری (ok / blocked / error) — یک درخواست مؤدبانه |
|
|
34
|
+
|
|
35
|
+
## توسعه
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python3 -m venv .venv && .venv/bin/pip install "mcp<2" httpx pytest
|
|
39
|
+
.venv/bin/pip install -e .
|
|
40
|
+
.venv/bin/python -m pytest tests/ -q
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## لایسنس
|
|
44
|
+
|
|
45
|
+
MIT
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
Built by [Mohammad Abbasi](https://github.com/mohammad-abbasi-sh) — [Almanibama](https://almanibama.ir) · [mabbasi.ir](https://mabbasi.ir)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# billiger-mcp 🛒
|
|
2
|
+
|
|
3
|
+
mcp-name: io.github.mohammad-abbasi-sh/billiger-mcp
|
|
4
|
+
|
|
5
|
+
Unofficial **read-only** MCP server for **[billiger.de](https://www.billiger.de)** — German price comparison from billiger.de (free, no key, no login): search products with best prices, compare shop offers, and today's deals. No key, no login.
|
|
6
|
+
|
|
7
|
+
> Built by Mohammad Abbasi as part of the "Germany MCP factory". Not affiliated with billiger.de.
|
|
8
|
+
|
|
9
|
+
## For AI agents
|
|
10
|
+
|
|
11
|
+
Add to your MCP client config (stdio):
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"billiger": {
|
|
17
|
+
"command": "uvx",
|
|
18
|
+
"args": ["billiger-mcp==0.1.0"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or run locally: `python -m billiger_mcp.server` (needs `mcp<2`, `httpx`).
|
|
25
|
+
|
|
26
|
+
## Tools
|
|
27
|
+
|
|
28
|
+
| Tool | Description |
|
|
29
|
+
|------|-------------|
|
|
30
|
+
| `billiger_search_prices` | Search billiger.de products by name: best price, offer count, rating — `query`, `limit` 1..20 |
|
|
31
|
+
| `billiger_product_offers` | Compare shop offers for one product (shop, price, shipping, total, delivery) — `product` (billiger.de URL, baseproducts id or slug), `limit` 1..20 |
|
|
32
|
+
| `billiger_best_deals` | Today's deals from the billiger.de home page: product, best price, offer count — `limit` 1..20 |
|
|
33
|
+
| `billiger_health` | Reachability probe (ok / blocked / error) — one polite request |
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python3 -m venv .venv && .venv/bin/pip install "mcp<2" httpx pytest
|
|
39
|
+
.venv/bin/pip install -e .
|
|
40
|
+
.venv/bin/python -m pytest tests/ -q
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
Built by [Mohammad Abbasi](https://github.com/mohammad-abbasi-sh) — [Almanibama](https://almanibama.ir) · [mabbasi.ir](https://mabbasi.ir)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "billiger-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Unofficial read-only MCP server for billiger.de — German price comparison"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"mcp<2",
|
|
14
|
+
"httpx>=0.27",
|
|
15
|
+
]
|
|
16
|
+
authors = [{ name = "Mohammad Abbasi" }]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
billiger-mcp = "billiger_mcp.server:main"
|
|
20
|
+
|
|
21
|
+
[tool.hatch.build.targets.wheel]
|
|
22
|
+
packages = ["src/billiger_mcp"]
|
|
23
|
+
|
|
24
|
+
[tool.pytest.ini_options]
|
|
25
|
+
markers = ["live: tests that hit the real https://www.billiger.de site"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json", "description": "Unofficial read-only MCP server for billiger.de — German price comparison.", "name": "io.github.mohammad-abbasi-sh/billiger-mcp", "packages": [{"identifier": "billiger-mcp", "registryBaseUrl": "https://pypi.org", "registryType": "pypi", "transport": {"type": "stdio"}, "version": "0.1.0"}], "repository": {"source": "github", "url": "https://github.com/mohammad-abbasi-sh/billiger-mcp"}, "title": "billiger.de — German price comparison: best prices, shop offers & deals", "version": "0.1.0", "websiteUrl": "https://github.com/mohammad-abbasi-sh/billiger-mcp"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""billiger_mcp — unofficial read-only MCP server for billiger.de.
|
|
2
|
+
|
|
3
|
+
German price comparison from billiger.de (free, no key, no login): search products with best prices, compare shop offers, and today's deals.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"""Domain logic: shape billiger.de's server-rendered HTML into
|
|
2
|
+
compact dicts (stdlib only, regex parsers).
|
|
3
|
+
|
|
4
|
+
Data source: https://www.billiger.de — free, no key, no login.
|
|
5
|
+
The site sits behind Cloudflare: a bare UA + Accept gets the 403
|
|
6
|
+
"Just a moment..." challenge page; the full browser navigation
|
|
7
|
+
header set in http.py (sec-ch-ua / sec-fetch, verified 2026-11-10)
|
|
8
|
+
lets the real HTML through.
|
|
9
|
+
|
|
10
|
+
Pages (verified 2026-11-10):
|
|
11
|
+
- GET /search?searchstring=<q> — 302s to the matching category
|
|
12
|
+
page (e.g. /categories/4373/53176-apple-handys-ohne-vertrag) or
|
|
13
|
+
to /noresult?searchstring=<q> when nothing matches.
|
|
14
|
+
- Product cards (search + home share the structure):
|
|
15
|
+
<a href="/baseproducts/<id>-<slug>" title="<name>"> …
|
|
16
|
+
<span class="line-clamp-2…"> <name> </span> …
|
|
17
|
+
<div … data-bde-price=""> <strong … data-price> <span>ab</span>
|
|
18
|
+
839,99 €* </strong> </div> … <div> 418 Preise vergleichen </div>
|
|
19
|
+
rating: <div … style="--rating: 92"></div> <span>(173)</span>
|
|
20
|
+
- GET /baseproducts/<id>-<slug> — product page; offer rows are
|
|
21
|
+
<div … data-product-id="<offer-id>" data-bde-card=""> …
|
|
22
|
+
variant <div … title="<variant>">, shop <img alt="Shop <shop>">,
|
|
23
|
+
seller "Verkäufer: <name>" + --rating, price <span data-price>
|
|
24
|
+
877,89 €*, "ab 0,00 € Versand", "877,89 € Gesamt",
|
|
25
|
+
"Lieferzeit: 1-5 Werktage". First 20 offers are SSR; the page
|
|
26
|
+
total (e.g. 385) is in the meta description.
|
|
27
|
+
- GET / (home) — deals: same product-card structure; 37
|
|
28
|
+
/baseproducts/ links on 2026-11-10.
|
|
29
|
+
- Price history: NOT in the SSR HTML — the chart is a JS
|
|
30
|
+
component (data-pricehistory-container, empty server-side) with
|
|
31
|
+
no data endpoint in the page. No price_history tool: the data
|
|
32
|
+
is not fetchable read-only from the HTML.
|
|
33
|
+
"""
|
|
34
|
+
from __future__ import annotations
|
|
35
|
+
|
|
36
|
+
import html as _html
|
|
37
|
+
import re
|
|
38
|
+
from urllib.parse import quote_plus
|
|
39
|
+
|
|
40
|
+
BASE = "https://www.billiger.de"
|
|
41
|
+
|
|
42
|
+
_CARD_RE = re.compile(
|
|
43
|
+
r'<a[^>]+href="/baseproducts/(\d+)-([^"]+)"[^>]*>',
|
|
44
|
+
re.IGNORECASE)
|
|
45
|
+
_NAME_RE = re.compile(
|
|
46
|
+
r'<span class="line-clamp-2[^"]*">\s*([^<]+?)\s*</span>')
|
|
47
|
+
_PRICE_RE = re.compile(
|
|
48
|
+
r'data-(?:sales-)?price[^>]*>(?:\s*<span[^>]*>ab</span>)?\s*([\d.]+,\d{2})\s*€')
|
|
49
|
+
_WAS_PRICE_RE = re.compile(
|
|
50
|
+
r'line-through">([\d.]+,\d{2})\s*€</span>')
|
|
51
|
+
_OFFERS_RE = re.compile(r'(\d[\d.]*)\s+Preise vergleichen')
|
|
52
|
+
_RATING_RE = re.compile(r'--rating:\s*(\d+)')
|
|
53
|
+
_REVIEWS_RE = re.compile(r'\((\d+)\)')
|
|
54
|
+
|
|
55
|
+
_OFFER_RE = re.compile(r'data-product-id="(\d+)"')
|
|
56
|
+
_VARIANT_RE = re.compile(
|
|
57
|
+
r'<div class="order-1[^"]*" title="([^"]+)">')
|
|
58
|
+
_SHOP_RE = re.compile(r'<img[^>]+alt="Shop ([^"]+)"')
|
|
59
|
+
_SELLER_RE = re.compile(r'Verkäufer:\s*([^"<]+)')
|
|
60
|
+
_SHIP_RE = re.compile(r'ab\s+([\d.]+,\d{2})\s*€ Versand')
|
|
61
|
+
_TOTAL_RE = re.compile(r'([\d.]+,\d{2})\s*€ Gesamt')
|
|
62
|
+
_DELIVERY_RE = re.compile(r'Lieferzeit:\s*([^<]+)')
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def validate_query(query: str) -> str:
|
|
66
|
+
q = (query or "").strip()
|
|
67
|
+
if not q:
|
|
68
|
+
raise ValueError("query must not be empty")
|
|
69
|
+
if len(q) > 100:
|
|
70
|
+
raise ValueError("query too long (max 100 characters)")
|
|
71
|
+
return q
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def validate_limit(limit: int, maximum: int = 20) -> int:
|
|
75
|
+
if not 1 <= limit <= maximum:
|
|
76
|
+
raise ValueError(
|
|
77
|
+
f"limit out of range: {limit} (expected 1..{maximum})")
|
|
78
|
+
return limit
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def search_url(query: str) -> str:
|
|
82
|
+
return f"{BASE}/search?searchstring={quote_plus(query)}"
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def resolve_product_url(product: str) -> str:
|
|
86
|
+
"""Full billiger.de URL, a baseproducts slug, or a bare numeric
|
|
87
|
+
id (the site 301s /baseproducts/<id> to the canonical slug
|
|
88
|
+
URL)."""
|
|
89
|
+
p = (product or "").strip()
|
|
90
|
+
if not p:
|
|
91
|
+
raise ValueError("product must not be empty")
|
|
92
|
+
if p.startswith("http"):
|
|
93
|
+
if "billiger.de/baseproducts/" not in p:
|
|
94
|
+
raise ValueError(
|
|
95
|
+
"product URL must be a billiger.de /baseproducts/ URL")
|
|
96
|
+
return p
|
|
97
|
+
if p.startswith("/baseproducts/"):
|
|
98
|
+
return BASE + p
|
|
99
|
+
m = re.match(r"^(\d+)(?:-([A-Za-z0-9-]+))?$", p)
|
|
100
|
+
if not m:
|
|
101
|
+
raise ValueError(
|
|
102
|
+
"product must be a billiger.de URL, a baseproducts slug "
|
|
103
|
+
"(e.g. 114326-apple-iphone-17) or a numeric id")
|
|
104
|
+
if m.group(2):
|
|
105
|
+
return f"{BASE}/baseproducts/{m.group(1)}-{m.group(2)}"
|
|
106
|
+
return f"{BASE}/baseproducts/{m.group(1)}"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def parse_de_price(text: str) -> float:
|
|
110
|
+
"""German price string ("2.999,00") -> float."""
|
|
111
|
+
return float(text.replace(".", "").replace(",", "."))
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def parse_cards(page_html: str) -> list[dict]:
|
|
115
|
+
"""Product cards from a search/category/home page, deduped by
|
|
116
|
+
product id, in page order. [] when the page has no products
|
|
117
|
+
(e.g. the /noresult page)."""
|
|
118
|
+
out: list[dict] = []
|
|
119
|
+
seen: set[str] = set()
|
|
120
|
+
for m in _CARD_RE.finditer(page_html):
|
|
121
|
+
pid, slug = m.group(1), m.group(2)
|
|
122
|
+
if pid in seen:
|
|
123
|
+
continue
|
|
124
|
+
seen.add(pid)
|
|
125
|
+
chunk = page_html[m.start():m.start() + 2500]
|
|
126
|
+
name_m = _NAME_RE.search(chunk)
|
|
127
|
+
price_m = _PRICE_RE.search(chunk)
|
|
128
|
+
offers_m = _OFFERS_RE.search(chunk)
|
|
129
|
+
rating_m = _RATING_RE.search(chunk)
|
|
130
|
+
reviews_m = _REVIEWS_RE.search(chunk)
|
|
131
|
+
name = _html.unescape(
|
|
132
|
+
name_m.group(1).strip()) if name_m else None
|
|
133
|
+
# fallback: the link's title attribute
|
|
134
|
+
if not name:
|
|
135
|
+
t = re.search(r'title="([^"]+)"', m.group(0))
|
|
136
|
+
name = _html.unescape(t.group(1)) if t else slug
|
|
137
|
+
out.append({
|
|
138
|
+
"id": pid,
|
|
139
|
+
"name": name,
|
|
140
|
+
"url": f"{BASE}/baseproducts/{pid}-{slug}",
|
|
141
|
+
"price_from_eur": (parse_de_price(price_m.group(1))
|
|
142
|
+
if price_m else None),
|
|
143
|
+
"offers": (int(offers_m.group(1).replace(".", ""))
|
|
144
|
+
if offers_m else None),
|
|
145
|
+
"rating_pct": int(rating_m.group(1)) if rating_m else None,
|
|
146
|
+
"reviews": int(reviews_m.group(1)) if reviews_m else None,
|
|
147
|
+
})
|
|
148
|
+
return out
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def parse_offers(page_html: str) -> dict:
|
|
152
|
+
"""{product_name, price_from_eur, total_offers, offers: [{shop,
|
|
153
|
+
seller, variant, price_eur, shipping_eur, total_eur,
|
|
154
|
+
delivery, shop_rating_pct}]} — first 20 offers are SSR."""
|
|
155
|
+
name_m = re.search(
|
|
156
|
+
r'<meta property="og:title" content="([^"]+?)(?:💥|$)', page_html)
|
|
157
|
+
total_m = re.search(r'–\s*([\d.]+)\s+Angebote', page_html)
|
|
158
|
+
offers: list[dict] = []
|
|
159
|
+
for m in _OFFER_RE.finditer(page_html):
|
|
160
|
+
chunk = page_html[m.start():m.start() + 4500]
|
|
161
|
+
variant_m = _VARIANT_RE.search(chunk)
|
|
162
|
+
shop_m = _SHOP_RE.search(chunk)
|
|
163
|
+
seller_m = _SELLER_RE.search(chunk)
|
|
164
|
+
price_m = _PRICE_RE.search(chunk)
|
|
165
|
+
was_m = _WAS_PRICE_RE.search(chunk)
|
|
166
|
+
ship_m = _SHIP_RE.search(chunk)
|
|
167
|
+
total_m2 = _TOTAL_RE.search(chunk)
|
|
168
|
+
deliv_m = _DELIVERY_RE.search(chunk)
|
|
169
|
+
rating_m = _RATING_RE.search(chunk)
|
|
170
|
+
if not shop_m and not price_m:
|
|
171
|
+
continue
|
|
172
|
+
offers.append({
|
|
173
|
+
"shop": shop_m.group(1) if shop_m else None,
|
|
174
|
+
"seller": (seller_m.group(1).strip()
|
|
175
|
+
if seller_m else None),
|
|
176
|
+
"variant": (variant_m.group(1).strip()
|
|
177
|
+
if variant_m else None),
|
|
178
|
+
"price_eur": (parse_de_price(price_m.group(1))
|
|
179
|
+
if price_m else None),
|
|
180
|
+
"was_price_eur": (parse_de_price(was_m.group(1))
|
|
181
|
+
if was_m else None),
|
|
182
|
+
"shipping_eur": (parse_de_price(ship_m.group(1))
|
|
183
|
+
if ship_m else None),
|
|
184
|
+
"total_eur": (parse_de_price(total_m2.group(1))
|
|
185
|
+
if total_m2 else None),
|
|
186
|
+
"delivery": (deliv_m.group(1).strip()
|
|
187
|
+
if deliv_m else None),
|
|
188
|
+
"shop_rating_pct": (int(rating_m.group(1))
|
|
189
|
+
if rating_m else None),
|
|
190
|
+
})
|
|
191
|
+
return {
|
|
192
|
+
"product_name": (_html.unescape(name_m.group(1).strip())
|
|
193
|
+
if name_m else None),
|
|
194
|
+
"total_offers": (int(total_m.group(1).replace(".", ""))
|
|
195
|
+
if total_m else len(offers)),
|
|
196
|
+
"offers": offers,
|
|
197
|
+
}
|