extsearch 2.0.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.
- extsearch-2.0.0/LICENSE +21 -0
- extsearch-2.0.0/PKG-INFO +545 -0
- extsearch-2.0.0/README.md +512 -0
- extsearch-2.0.0/extsearch/__init__.py +38 -0
- extsearch-2.0.0/extsearch/api.py +202 -0
- extsearch-2.0.0/extsearch/catalog.py +1122 -0
- extsearch-2.0.0/extsearch/catalog_extra.py +452 -0
- extsearch-2.0.0/extsearch/cli.py +224 -0
- extsearch-2.0.0/extsearch/config.py +80 -0
- extsearch-2.0.0/extsearch/details.py +480 -0
- extsearch-2.0.0/extsearch/errors.py +83 -0
- extsearch-2.0.0/extsearch/junk_words.txt +375 -0
- extsearch-2.0.0/extsearch/marketplaces/__init__.py +192 -0
- extsearch-2.0.0/extsearch/marketplaces/adapters.py +761 -0
- extsearch-2.0.0/extsearch/marketplaces/asia.py +50 -0
- extsearch-2.0.0/extsearch/marketplaces/cis.py +34 -0
- extsearch-2.0.0/extsearch/marketplaces/eu.py +65 -0
- extsearch-2.0.0/extsearch/marketplaces/global_.py +32 -0
- extsearch-2.0.0/extsearch/marketplaces/ru.py +28 -0
- extsearch-2.0.0/extsearch/marketplaces/ua.py +83 -0
- extsearch-2.0.0/extsearch/marketplaces/us.py +46 -0
- extsearch-2.0.0/extsearch/mcp_server.py +244 -0
- extsearch-2.0.0/extsearch/media.py +79 -0
- extsearch-2.0.0/extsearch/net.py +167 -0
- extsearch-2.0.0/extsearch/olx.py +1055 -0
- extsearch-2.0.0/extsearch/proxies.py +152 -0
- extsearch-2.0.0/extsearch/search.py +351 -0
- extsearch-2.0.0/extsearch/sources.py +286 -0
- extsearch-2.0.0/extsearch/web.py +324 -0
- extsearch-2.0.0/extsearch.egg-info/PKG-INFO +545 -0
- extsearch-2.0.0/extsearch.egg-info/SOURCES.txt +35 -0
- extsearch-2.0.0/extsearch.egg-info/dependency_links.txt +1 -0
- extsearch-2.0.0/extsearch.egg-info/entry_points.txt +4 -0
- extsearch-2.0.0/extsearch.egg-info/requires.txt +21 -0
- extsearch-2.0.0/extsearch.egg-info/top_level.txt +1 -0
- extsearch-2.0.0/pyproject.toml +48 -0
- extsearch-2.0.0/setup.cfg +4 -0
extsearch-2.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 viitlk
|
|
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.
|
extsearch-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: extsearch
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Product search across marketplaces of many countries: library, MCP server and HTTP API
|
|
5
|
+
Author: viitlk
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/viitlk/extSearch
|
|
8
|
+
Project-URL: Issues, https://github.com/viitlk/extSearch/issues
|
|
9
|
+
Keywords: marketplaces,scraping,search,mcp,prices,olx,amazon
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: curl_cffi>=0.7
|
|
17
|
+
Requires-Dist: beautifulsoup4>=4.12
|
|
18
|
+
Provides-Extra: mcp
|
|
19
|
+
Requires-Dist: mcp>=2.0; extra == "mcp"
|
|
20
|
+
Provides-Extra: api
|
|
21
|
+
Requires-Dist: fastapi>=0.110; extra == "api"
|
|
22
|
+
Requires-Dist: uvicorn>=0.30; extra == "api"
|
|
23
|
+
Provides-Extra: browser
|
|
24
|
+
Requires-Dist: playwright>=1.40; extra == "browser"
|
|
25
|
+
Provides-Extra: all
|
|
26
|
+
Requires-Dist: mcp>=2.0; extra == "all"
|
|
27
|
+
Requires-Dist: fastapi>=0.110; extra == "all"
|
|
28
|
+
Requires-Dist: uvicorn>=0.30; extra == "all"
|
|
29
|
+
Requires-Dist: playwright>=1.40; extra == "all"
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# extsearch
|
|
35
|
+
|
|
36
|
+
[](https://www.python.org/)
|
|
37
|
+
[](LICENSE)
|
|
38
|
+
[](https://modelcontextprotocol.io/)
|
|
39
|
+
|
|
40
|
+
Product search across marketplaces of many countries. 39 marketplaces in 17
|
|
41
|
+
countries, one result format, one error format, no API keys. One engine, three
|
|
42
|
+
interfaces:
|
|
43
|
+
|
|
44
|
+
| Interface | Command | Use it from |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| Python library | `import extsearch` | scripts, bots, your own services |
|
|
47
|
+
| MCP server | `extsearch-mcp` | LLM agents (OpenCode, Claude, Cline, any MCP client) |
|
|
48
|
+
| HTTP API | `extsearch-api` | anything that speaks HTTP, plus a `/docs` UI |
|
|
49
|
+
|
|
50
|
+
**Documentation:** [docs/](docs/index.md) — [library](docs/library.md) ·
|
|
51
|
+
[HTTP API](docs/api.md) · [MCP server](docs/mcp.md) ·
|
|
52
|
+
[architecture](docs/architecture.md) ·
|
|
53
|
+
[adding a marketplace](docs/adding-a-marketplace.md) ·
|
|
54
|
+
[troubleshooting](docs/troubleshooting.md)
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import asyncio
|
|
58
|
+
from extsearch import search, select
|
|
59
|
+
|
|
60
|
+
async def main():
|
|
61
|
+
res = await search("fifine k669", where="ua", limit=5, sort="cheapest")
|
|
62
|
+
for item in res["items"]:
|
|
63
|
+
print(item["price"], item["currency"], item["source"], "—", item["title"])
|
|
64
|
+
|
|
65
|
+
card = await select(res["items"][0]["id"]) # "olx:940356105"
|
|
66
|
+
print(card["title"], card.get("delivery"))
|
|
67
|
+
|
|
68
|
+
asyncio.run(main())
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
> [!NOTE]
|
|
72
|
+
> Many marketplaces check the TLS fingerprint, so the transport is `curl_cffi`, not
|
|
73
|
+
> `requests`/`httpx`. Plain HTTP clients receive `403` even with correct headers.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Why another scraper
|
|
78
|
+
|
|
79
|
+
Most "marketplace API" projects are one site, one country and one output shape.
|
|
80
|
+
This one is built around a small adapter contract:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
search(query, where) ──┬── olx (JSON API) ─────┐
|
|
84
|
+
├── shops (HTML) ────────┤── merge ── rank ── items[]
|
|
85
|
+
└── foreign (HTML/JSON) ─┘
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Each adapter returns the same rows (`id, title, price, currency, relevance, …`),
|
|
89
|
+
so filters, sorting, currency conversion and the id → product-card map work
|
|
90
|
+
identically for a Ukrainian classified site and a Japanese marketplace.
|
|
91
|
+
|
|
92
|
+
Adding a marketplace is one function plus one registry line — see
|
|
93
|
+
[`extsearch/marketplaces/`](extsearch/marketplaces/).
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Countries and marketplaces
|
|
98
|
+
|
|
99
|
+
`where=` accepts countries, marketplaces, or both: `"ua"`, `"ua,ru"`,
|
|
100
|
+
`"olx,ozon"`, `"all"`, `"all,-ru"`, `"eu"`, `"cis"`.
|
|
101
|
+
|
|
102
|
+
| Code | Country | Marketplaces |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| `ua` | Ukraine | olx, prom, foxtrot, rozetka, comfy, allo, moyo, kasta, brain, ctrs, bigl, epicentr, makeup, shafa, auto¹ |
|
|
105
|
+
| `pl` | Poland | olx_pl, allegro² |
|
|
106
|
+
| `ro` / `bg` / `pt` | Romania / Bulgaria / Portugal | olx_ro, olx_bg, olx_pt |
|
|
107
|
+
| `kz` / `uz` | Kazakhstan / Uzbekistan | olx_kz, kaspi², olx_uz |
|
|
108
|
+
| `ru` | Russia | yandex_market, wildberries², ozon² |
|
|
109
|
+
| `us` | USA | amazon², ebay², walmart² |
|
|
110
|
+
| `gb` / `de` / `fr` / `it` / `es` | United Kingdom / Germany / France / Italy / Spain | amazon_gb², amazon_de, amazon_fr², amazon_it², amazon_es² |
|
|
111
|
+
| `jp` / `in` / `sg` | Japan / India / Singapore | rakuten, flipkart², shopee_sg² |
|
|
112
|
+
| `global` | worldwide | aliexpress, alibaba² |
|
|
113
|
+
|
|
114
|
+
Group tokens: `eu` (pl, ro, bg, pt, de, gb, fr, it, es), `cis` (kz, uz).
|
|
115
|
+
|
|
116
|
+
¹ opt-in: excluded from `all` because it is a different vertical (cars).
|
|
117
|
+
² needs a proxy in a supported region — the marketplace answers `403`/`444` to
|
|
118
|
+
requests from the "wrong" country. The adapter is written; the status is
|
|
119
|
+
reported as `verified: false` until someone confirms it from a matching IP.
|
|
120
|
+
|
|
121
|
+
### Verification status
|
|
122
|
+
|
|
123
|
+
`sources_catalog()` (MCP: `marketplace_catalog`, API: `GET /sources`) reports
|
|
124
|
+
per marketplace:
|
|
125
|
+
|
|
126
|
+
| Field | Meaning |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `verified` | markup confirmed by a real run, parser returns items |
|
|
129
|
+
| `needs_proxy` | answers `403`/`429`/`444` without a regional proxy |
|
|
130
|
+
| `default` | included in `all` and in country-wide searches |
|
|
131
|
+
| `can_get` | product cards (`select`) supported |
|
|
132
|
+
|
|
133
|
+
Verified: OLX (ua, pl, ro, bg, pt, kz, uz), prom, foxtrot, comfy, allo, moyo,
|
|
134
|
+
kasta, brain, ctrs, bigl, epicentr, makeup, auto.ria, yandex_market, rakuten,
|
|
135
|
+
aliexpress, amazon.de, plus Rozetka's product API.
|
|
136
|
+
Rozetka **search** needs a warmed browser profile: `python tools/warmup_rozetka.py`.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Install
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
git clone https://github.com/viitlk/extSearch
|
|
144
|
+
cd extSearch
|
|
145
|
+
|
|
146
|
+
python -m venv .venv
|
|
147
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
148
|
+
|
|
149
|
+
pip install -e ".[all]" # library + MCP + HTTP API
|
|
150
|
+
# or minimal, library only:
|
|
151
|
+
pip install -e .
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Optional browser engine (Rozetka search only):
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
pip install playwright && python -m playwright install chromium
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Requirements: Python 3.10+, `curl_cffi`, `beautifulsoup4`. Linux and macOS are
|
|
161
|
+
the tested platforms; Windows should work but is not covered by CI.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Library
|
|
166
|
+
|
|
167
|
+
### Search
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
import asyncio
|
|
171
|
+
from extsearch import search
|
|
172
|
+
|
|
173
|
+
async def main():
|
|
174
|
+
res = await search(
|
|
175
|
+
"iphone 15",
|
|
176
|
+
where="ua,pl", # countries and/or marketplace names
|
|
177
|
+
limit=10, # items in the response, 1..50
|
|
178
|
+
page=1,
|
|
179
|
+
price_min=500,
|
|
180
|
+
price_max=1500,
|
|
181
|
+
sort="cheapest", # relevance|newest|cheapest|expensive|rating|...
|
|
182
|
+
min_rating=4.0, # drops items without a rating
|
|
183
|
+
strict=True, # title must contain a query word
|
|
184
|
+
details=2, # delivery/payment for the first 2 items
|
|
185
|
+
)
|
|
186
|
+
for item in res["items"]:
|
|
187
|
+
print(item["id"], item["price"], item["currency"], item["title"])
|
|
188
|
+
print(res["sources"]) # per marketplace: returned / total / error / hint
|
|
189
|
+
|
|
190
|
+
asyncio.run(main())
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
<details>
|
|
194
|
+
<summary>Response shape (abridged)</summary>
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"query": "iphone 15",
|
|
199
|
+
"where": ["olx", "prom", "olx_pl"],
|
|
200
|
+
"countries": ["pl", "ua"],
|
|
201
|
+
"returned": 2,
|
|
202
|
+
"sort": "cheapest",
|
|
203
|
+
"sources": {
|
|
204
|
+
"olx": {"returned": 10, "total": 1843},
|
|
205
|
+
"olx_pl": {"returned": 10, "total": 214},
|
|
206
|
+
"prom": {"returned": 0, "error": "blocked", "hint": "route it through a proxy ..."}
|
|
207
|
+
},
|
|
208
|
+
"items": [
|
|
209
|
+
{
|
|
210
|
+
"id": "olx:940356105",
|
|
211
|
+
"source": "olx",
|
|
212
|
+
"country": "ua",
|
|
213
|
+
"title": "iPhone 15 128GB Black",
|
|
214
|
+
"price": 18900,
|
|
215
|
+
"currency": "UAH",
|
|
216
|
+
"price_usd": 453.6,
|
|
217
|
+
"relevance": 1.0,
|
|
218
|
+
"url": "https://www.olx.ua/d/uk/obyavlenie/..."
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"notes": ["mixed currencies (PLN, UAH); prices are compared via the approximate price_usd"]
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
</details>
|
|
226
|
+
|
|
227
|
+
### Product card
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
card = await select("amazon:B0BZP61K18", max_description_chars=400)
|
|
231
|
+
card["title"]; card["price"]; card.get("delivery"); card.get("reviews")
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Cards may include `delivery[]`, `payment[]`, `reviews`, `free_shipping_from`.
|
|
235
|
+
A `null` delivery price means the shop does not publish a fixed price and
|
|
236
|
+
charges the carrier rate — it is not "unknown".
|
|
237
|
+
|
|
238
|
+
### Catalog and resolution
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
from extsearch import resolve, sources_catalog
|
|
242
|
+
|
|
243
|
+
resolve("ua") # ['allo', 'bigl', 'brain', ...]
|
|
244
|
+
resolve("all,-ru,-auto") # everything except Russia and AUTO.RIA
|
|
245
|
+
resolve("eu")
|
|
246
|
+
|
|
247
|
+
sources_catalog()["countries"] # code -> {title, marketplaces}
|
|
248
|
+
sources_catalog()["marketplaces"][0] # name, currency, verified, needs_proxy, ...
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Errors
|
|
252
|
+
|
|
253
|
+
Every failure is one shape, language-neutral, with a machine-readable code:
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
from extsearch import ExtSearchError
|
|
257
|
+
|
|
258
|
+
try:
|
|
259
|
+
await search("iphone", where="ozon")
|
|
260
|
+
except ExtSearchError as exc:
|
|
261
|
+
exc.code # "blocked"
|
|
262
|
+
exc.message # "www.ozon.ru rejected the request (HTTP 403)"
|
|
263
|
+
exc.hint # 'route it through a proxy (proxies=["TYPE://IP:PORT"])'
|
|
264
|
+
exc.retryable # True
|
|
265
|
+
exc.as_dict() # JSON-ready payload
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Codes: `bad_argument`, `not_found`, `blocked`, `needs_proxy`, `rate_limited`,
|
|
269
|
+
`network`, `timeout`, `no_results`, `no_state`, `no_url`, `unavailable`,
|
|
270
|
+
`browser_unavailable`, `server_error`, `http_error`, `bad_response`.
|
|
271
|
+
|
|
272
|
+
A partial failure never kills a search: the response lists per-marketplace
|
|
273
|
+
status in `sources` and explanations in `notes`. If exactly one marketplace was
|
|
274
|
+
requested, its own error is raised instead of a generic `no_results`.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Proxies
|
|
279
|
+
|
|
280
|
+
Format `TYPE://IP:PORT`; `TYPE` is `http`, `https`, `socks4` or `socks5`.
|
|
281
|
+
Credentials are allowed: `socks5://user:pass@1.2.3.4:1080`.
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
# environment
|
|
285
|
+
export EXTSEARCH_PROXIES="socks5://1.2.3.4:1080,http://5.6.7.8:3128"
|
|
286
|
+
|
|
287
|
+
# CLI
|
|
288
|
+
extsearch search "iphone" -w us --proxy socks5://1.2.3.4:1080
|
|
289
|
+
|
|
290
|
+
# library
|
|
291
|
+
from extsearch import set_proxies
|
|
292
|
+
set_proxies(["socks5://1.2.3.4:1080"])
|
|
293
|
+
|
|
294
|
+
# per call
|
|
295
|
+
await search("iphone", where="us", proxies=["socks5://1.2.3.4:1080"])
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Proxies rotate round-robin. One that produces a network error or `403`/`429` is
|
|
299
|
+
skipped for 120 seconds and the request retries on the next proxy. Credentials
|
|
300
|
+
are masked in logs and API responses.
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## CLI
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
extsearch search "fifine k669" -w ua -n 5
|
|
308
|
+
extsearch search "iphone 15" -w all --sort cheapest --proxy socks5://1.2.3.4:1080
|
|
309
|
+
extsearch search "rtx 4060" -w ru,ua --min-price 8000 --details 2
|
|
310
|
+
extsearch select amazon:B0BZP61K18
|
|
311
|
+
extsearch sources --country ru
|
|
312
|
+
extsearch web "python asyncio gather" --fetch-top 2
|
|
313
|
+
extsearch video "fifine k669 review"
|
|
314
|
+
extsearch freelance "telegram bot aiogram"
|
|
315
|
+
extsearch mcp # MCP server over stdio
|
|
316
|
+
extsearch api --port 8000 # HTTP API
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## HTTP API
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
extsearch-api --host 127.0.0.1 --port 8000
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
OpenAPI docs and a try-it form: <http://127.0.0.1:8000/docs>
|
|
328
|
+
|
|
329
|
+
| Method | Path | Purpose |
|
|
330
|
+
|---|---|---|
|
|
331
|
+
| GET | `/health` | status, version, proxy count |
|
|
332
|
+
| GET | `/sources` | countries, marketplaces, flags |
|
|
333
|
+
| GET | `/search?q=...&where=ua&limit=5` | quick search |
|
|
334
|
+
| POST | `/search` | full search (`SearchBody` schema) |
|
|
335
|
+
| GET | `/item/{id}` | product card |
|
|
336
|
+
| GET / POST | `/proxies` | inspect / replace the pool |
|
|
337
|
+
| GET | `/web/search`, `/web/get` | web search, page text |
|
|
338
|
+
| GET | `/video`, `/mods`, `/freelance` | content tools |
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
curl "127.0.0.1:8000/search?q=fifine%20k669&where=ua&limit=3"
|
|
342
|
+
curl "127.0.0.1:8000/item/olx:940356105"
|
|
343
|
+
|
|
344
|
+
curl -X POST 127.0.0.1:8000/search \
|
|
345
|
+
-H 'content-type: application/json' \
|
|
346
|
+
-d '{"query": "rtx 4060", "where": "ua,pl", "sort": "cheapest", "limit": 5}'
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Status codes map from error codes: `400` bad_argument, `404` not_found /
|
|
350
|
+
no_results, `409` no_url, `429` rate_limited, `501` unavailable, `502` blocked,
|
|
351
|
+
`504` timeout. Error bodies always carry `{error, message, hint?, retryable}`.
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## MCP server
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
extsearch-mcp # stdio (default)
|
|
359
|
+
EXTSEARCH_TRANSPORT=http extsearch-mcp --port 8765 # streamable HTTP
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Client configuration (OpenCode example; any MCP client works the same):
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{
|
|
366
|
+
"mcp": {
|
|
367
|
+
"extsearch": {
|
|
368
|
+
"type": "local",
|
|
369
|
+
"command": ["/path/to/.venv/bin/extsearch-mcp"],
|
|
370
|
+
"enabled": true
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Tools:
|
|
377
|
+
|
|
378
|
+
| Tool | What it does |
|
|
379
|
+
|---|---|
|
|
380
|
+
| `marketplace_search` | search across countries and marketplaces |
|
|
381
|
+
| `marketplace_select` | product card by `source:id` |
|
|
382
|
+
| `marketplace_catalog` | countries, marketplaces, verification flags |
|
|
383
|
+
| `configure_proxies` | set or clear the proxy pool |
|
|
384
|
+
| `web_search` / `web_get` | web search, clean page text |
|
|
385
|
+
| `video_search` | YouTube |
|
|
386
|
+
| `mod_search` | Modrinth + CurseForge |
|
|
387
|
+
| `freelance_search` | Kwork, Freelancehunt, Freelancer, Upwork, Fiverr |
|
|
388
|
+
|
|
389
|
+
Example prompts that work well:
|
|
390
|
+
|
|
391
|
+
```text
|
|
392
|
+
find fifine k669 on olx and prom under 2000 UAH, include delivery options
|
|
393
|
+
compare iphone 15 across ua, pl and de, cheapest first
|
|
394
|
+
show the marketplace catalog, then search ozon through socks5://1.2.3.4:1080
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## Tests
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
python tests/smoke_test.py # unit + live network
|
|
403
|
+
EXTSEARCH_OFFLINE=1 python tests/smoke_test.py # unit only
|
|
404
|
+
pytest tests/ -q
|
|
405
|
+
python tools/check_sources.py # per-marketplace health check
|
|
406
|
+
python tools/test.py # one-screen live test (for posts/issues)
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
The live part deliberately hits real marketplaces — that is the only way to
|
|
410
|
+
notice a layout change before users do.
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Configuration
|
|
415
|
+
|
|
416
|
+
Everything is environment-driven (see [`.env.example`](.env.example)):
|
|
417
|
+
|
|
418
|
+
| Variable | Default | Meaning |
|
|
419
|
+
|---|---|---|
|
|
420
|
+
| `EXTSEARCH_HOME` | `~/.local/share/extsearch` | cache and browser profile |
|
|
421
|
+
| `EXTSEARCH_PROXIES` | — | proxy list |
|
|
422
|
+
| `EXTSEARCH_TIMEOUT` | `25` | request timeout, seconds |
|
|
423
|
+
| `EXTSEARCH_MIN_INTERVAL` | `0.4` | pause between requests per process |
|
|
424
|
+
| `EXTSEARCH_CACHE_TTL` | `300` | response cache, seconds |
|
|
425
|
+
| `EXTSEARCH_FX` | built-in table | currency rates (USD per unit, JSON) |
|
|
426
|
+
| `EXTSEARCH_TRANSPORT` / `_HOST` / `_PORT` | `stdio` / `127.0.0.1` / `8765` | MCP transport |
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
## Layout
|
|
431
|
+
|
|
432
|
+
```text
|
|
433
|
+
extsearch/
|
|
434
|
+
search.py multi-marketplace search, ranking, FX, details
|
|
435
|
+
olx.py OLX engine — one codebase for 7 countries
|
|
436
|
+
catalog.py UA shops: prom, foxtrot, rozetka, comfy, allo, moyo, kasta, brain, citrus
|
|
437
|
+
catalog_extra.py UA shops: bigl, epicentr, makeup, shafa, auto.ria
|
|
438
|
+
marketplaces/ registry + adapters, split by country
|
|
439
|
+
details.py delivery / payment / reviews extraction
|
|
440
|
+
net.py curl_cffi sessions, throttling, cache, proxy rotation
|
|
441
|
+
proxies.py "TYPE://IP:PORT" parsing, round-robin pool
|
|
442
|
+
web.py web search and text extraction
|
|
443
|
+
sources.py YouTube, Modrinth, CurseForge, freelance boards
|
|
444
|
+
media.py wrappers for the content sources
|
|
445
|
+
mcp_server.py MCP tools
|
|
446
|
+
api.py FastAPI app
|
|
447
|
+
cli.py argparse CLI
|
|
448
|
+
docs/
|
|
449
|
+
index.md documentation map and concepts
|
|
450
|
+
library.md Python API reference
|
|
451
|
+
api.md HTTP endpoints and payloads
|
|
452
|
+
mcp.md MCP tools and client configuration
|
|
453
|
+
architecture.md request flow, adapter contract, network layer
|
|
454
|
+
adding-a-marketplace.md step-by-step guide with a real example
|
|
455
|
+
troubleshooting.md symptom → cause → fix
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## Limitations
|
|
461
|
+
|
|
462
|
+
- Scrapers break on redesigns. `sources` in every response and
|
|
463
|
+
`tools/check_sources.py` tell you which one broke.
|
|
464
|
+
- Prices are integers in the marketplace currency; Amazon/EUR cents are rounded.
|
|
465
|
+
Cross-country comparison uses an approximate FX table, not live rates.
|
|
466
|
+
- For marketplaces without numeric product ids the id → URL map is in memory,
|
|
467
|
+
so `select()` works for items found in the same process. Re-run the search if
|
|
468
|
+
the process restarted.
|
|
469
|
+
- Fourteen marketplaces answer `403`/`444` from the "wrong" country and are
|
|
470
|
+
marked `verified: false` until confirmed with a regional proxy.
|
|
471
|
+
- Product cards need a separate request per item: `details=N` costs N requests.
|
|
472
|
+
|
|
473
|
+
## Legal
|
|
474
|
+
|
|
475
|
+
This is a personal research tool. It does not bypass authentication, it reads
|
|
476
|
+
what a browser would read. Respect the terms of service of each marketplace and
|
|
477
|
+
your local law: keep request rates low, do not republish scraped content, use
|
|
478
|
+
only proxies you are allowed to use. Marketplace data belongs to the
|
|
479
|
+
marketplaces.
|
|
480
|
+
|
|
481
|
+
## Contributing
|
|
482
|
+
|
|
483
|
+
Adding a marketplace takes one file plus one registry line:
|
|
484
|
+
|
|
485
|
+
1. Write a parser that returns rows `{id, title, price, currency, relevance, url}`.
|
|
486
|
+
2. Register it in `extsearch/marketplaces/<country>.py` with `verified`/`needs_proxy`.
|
|
487
|
+
3. Add the name to the README table and run `python tools/check_sources.py my_source`.
|
|
488
|
+
|
|
489
|
+
Pull requests with a real example response (minus personal data) are welcome.
|
|
490
|
+
|
|
491
|
+
## Getting help
|
|
492
|
+
|
|
493
|
+
A marketplace changes its markup every few months, so "the parser broke" is a normal
|
|
494
|
+
event, not an exception.
|
|
495
|
+
|
|
496
|
+
| Situation | Where |
|
|
497
|
+
|---|---|
|
|
498
|
+
| a parser returns nothing or wrong prices | open an issue, the template asks for the details |
|
|
499
|
+
| usage question | [docs/](docs/index.md) first, then issues |
|
|
500
|
+
| a site answers `403` | that is regional blocking, see [proxies](docs/library.md#proxies) — a proxy is needed, not a patch |
|
|
501
|
+
| you want a new marketplace | [docs/adding-a-marketplace.md](docs/adding-a-marketplace.md), pull requests welcome |
|
|
502
|
+
|
|
503
|
+
Include this output when reporting a broken parser — it shows what works and what does not,
|
|
504
|
+
without guessing:
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
.venv/bin/python tools/test.py
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
## Support the project
|
|
511
|
+
|
|
512
|
+
Optional. Bug reports and pull requests help more than money.
|
|
513
|
+
|
|
514
|
+
**USDT (TRC20)** — cheapest network, accepted by every Ukrainian exchange
|
|
515
|
+
|
|
516
|
+

|
|
517
|
+
|
|
518
|
+
```text
|
|
519
|
+
TDkxURDpAuRAvTy78Tv23Z6DPCx1J1SRCd
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
**Bitcoin**
|
|
523
|
+
|
|
524
|
+

|
|
525
|
+
|
|
526
|
+
```text
|
|
527
|
+
bc1qj3d8qhnj377elgw5tk0z54zyn6xf7rnnvdx9y6
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
**Ethereum**
|
|
531
|
+
|
|
532
|
+

|
|
533
|
+
|
|
534
|
+
```text
|
|
535
|
+
0x946E80Be2330473ae5f2D09b3e861642D0487040
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
> [!WARNING]
|
|
539
|
+
> The network matters. USDT must be sent on **TRC20 (TRON)**. Sending the same
|
|
540
|
+
> token on BEP20 or ERC20 to this address loses the money — transfers are
|
|
541
|
+
> irreversible.
|
|
542
|
+
|
|
543
|
+
## License
|
|
544
|
+
|
|
545
|
+
MIT for the code, see [LICENSE](LICENSE).
|