ozon-grabber 0.1.6 → 1.0.0
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.
- package/README.md +34 -120
- package/dist/index.d.ts +2 -0
- package/dist/index.js +788 -895
- package/package.json +26 -30
package/README.md
CHANGED
|
@@ -1,140 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ozon-grabber
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI that scans your Ozon orders/returns via a real Chrome session and submits the parsed data to a SQLite-backed service.
|
|
4
4
|
|
|
5
|
-
The
|
|
6
|
-
`https://www.ozon.ru/my/orderdetails/?order=<userId>-<orderNumber>&selectedTab=archive`
|
|
7
|
-
and iterates order numbers in ascending order until it hits a missing or in-progress order.
|
|
5
|
+
The CLI launches Chrome through [chrome-devtools-mcp](https://www.npmjs.com/package/chrome-devtools-mcp), navigates the order/return pages it has access to, dumps each page's HTML, parses it locally with `jsdom`, and POSTs the result to a configurable backend (the companion service in [ozon-orders-history_v2/backend](https://github.com/isachivka/ozon-orders-history_v2/tree/main/backend)).
|
|
8
6
|
|
|
9
|
-
##
|
|
7
|
+
## Quick start
|
|
10
8
|
|
|
11
|
-
### Using npx (recommended)
|
|
12
|
-
|
|
13
|
-
You can run the tool without local installation:
|
|
14
9
|
```bash
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Local installation
|
|
10
|
+
# 1. log in once — Chrome opens, log in to Ozon, press Ctrl+C
|
|
11
|
+
npx ozon-grabber login
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
npm run build
|
|
24
|
-
node dist/index.js start --user-id <userId> --start-order 0001
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Requirements
|
|
28
|
-
|
|
29
|
-
- Node.js 20+
|
|
30
|
-
- Chrome/Chromium running with the remote debugging port `9222` enabled
|
|
31
|
-
- The user is already authenticated in Ozon in that browser
|
|
32
|
-
|
|
33
|
-
Example Chrome launch (macOS):
|
|
34
|
-
```bash
|
|
35
|
-
/Applications/Google\ Chrome\ Beta.app/Contents/MacOS/Google\ Chrome\ Beta \
|
|
36
|
-
--remote-debugging-port=9222 --user-data-dir=/tmp/chrome-beta-mcp
|
|
13
|
+
# 2. scan orders. user-id and backend-url are picked up from env;
|
|
14
|
+
# --start-order is fetched from the backend (auto-resume).
|
|
15
|
+
npx ozon-grabber start --verbose
|
|
37
16
|
|
|
17
|
+
# 3. scan returns
|
|
18
|
+
npx ozon-grabber start --returns --verbose
|
|
38
19
|
```
|
|
39
20
|
|
|
40
|
-
##
|
|
21
|
+
## Configuration
|
|
41
22
|
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npm login
|
|
45
|
-
```
|
|
46
|
-
2. **Verify build**:
|
|
47
|
-
```bash
|
|
48
|
-
npm run build
|
|
49
|
-
```
|
|
50
|
-
3. **Publish**:
|
|
51
|
-
```bash
|
|
52
|
-
npm publish --access public
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Run examples
|
|
23
|
+
Set these once in your shell profile (e.g. `~/.zshrc`):
|
|
56
24
|
|
|
57
25
|
```bash
|
|
58
|
-
|
|
59
|
-
|
|
26
|
+
export OZON_USER_ID=12345678
|
|
27
|
+
export OZON_BACKEND_URL=http://localhost:3000 # or your remote service
|
|
60
28
|
```
|
|
61
29
|
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
npx ozon-grabber start --user-id 30588125 --start-order 0001 --max-orders 5
|
|
65
|
-
```
|
|
30
|
+
Both can also be passed as flags (`--user-id`, `--backend-url`) — flags override env.
|
|
66
31
|
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
npx ozon-grabber start --user-id 30588125 --backend
|
|
70
|
-
```
|
|
71
|
-
When backend upload is enabled, each order is submitted immediately after parsing (fail-fast on upload errors).
|
|
72
|
-
|
|
73
|
-
Fetch the next order id from the backend:
|
|
74
|
-
```bash
|
|
75
|
-
npx ozon-grabber backend-next
|
|
76
|
-
```
|
|
77
|
-
This command uses the backend configuration options listed below.
|
|
78
|
-
|
|
79
|
-
## Parameters
|
|
80
|
-
|
|
81
|
-
Required:
|
|
82
|
-
- `--user-id <string>`: user identifier (e.g., `30588125`)
|
|
83
|
-
Optional:
|
|
84
|
-
- `--start-order <string>`: starting order number (e.g., `0001`); required when backend is disabled
|
|
85
|
-
- `--backend`: enable backend upload and backend-based start order resolution
|
|
86
|
-
|
|
87
|
-
Options:
|
|
88
|
-
- `--verbose`: verbose navigation and parsing logs
|
|
89
|
-
- `--max-orders <n>`: limit the number of orders to scan (debugging)
|
|
90
|
-
- `--page-load-timeout-ms <ms>`: how long to wait for order page widgets before declaring a missing order (default: `20000`)
|
|
91
|
-
- `--output <path>`: output file path; if the extension is `.csv`, CSV is used, otherwise JSON
|
|
92
|
-
- `--backend-url <url>`: backend base URL (env: `BACKEND_URL`, default: `http://localhost:3015`)
|
|
93
|
-
- `--backend-api-key <token>`: backend API key (env: `BACKEND_API_KEY`, default: `local-dev`)
|
|
94
|
-
|
|
95
|
-
## Output format (JSON)
|
|
96
|
-
|
|
97
|
-
```json
|
|
98
|
-
{
|
|
99
|
-
"userId": "30588125",
|
|
100
|
-
"startOrder": "0001",
|
|
101
|
-
"scannedOrders": 3,
|
|
102
|
-
"stopReason": "in-progress",
|
|
103
|
-
"stopOrderNumber": "0004",
|
|
104
|
-
"orders": [
|
|
105
|
-
{
|
|
106
|
-
"orderId": "30588125-0001",
|
|
107
|
-
"orderNumber": "0001",
|
|
108
|
-
"orderDate": "2026-01-09",
|
|
109
|
-
"items": [
|
|
110
|
-
{
|
|
111
|
-
"title": "...",
|
|
112
|
-
"price": "...",
|
|
113
|
-
"imageUrl": "..."
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
```
|
|
32
|
+
## Flags
|
|
120
33
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
-
|
|
124
|
-
|
|
34
|
+
| Flag | Default | Purpose |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `--user-id` | `$OZON_USER_ID` | Ozon account id (required if env unset) |
|
|
37
|
+
| `--start-order` | from `GET /scan-state/<user-id>` | Where to begin. Omit to resume |
|
|
38
|
+
| `--max-orders` | unlimited | Cap how many to scan in this run |
|
|
39
|
+
| `--returns` | `false` | Scan returns (`/my/returnDetails`) instead of orders |
|
|
40
|
+
| `--output <path>` | stdout | Where to write the JSON summary |
|
|
41
|
+
| `--backend-url` | `$OZON_BACKEND_URL` or `http://localhost:3000` | Submit URL |
|
|
42
|
+
| `--backend` / `--no-backend` | `true` | Submit POST per parsed result (or skip with `--no-backend`) |
|
|
43
|
+
| `--user-data-dir` | `./chrome-profile` | Chrome profile directory (cookies + login persisted here) |
|
|
44
|
+
| `--verbose` | `false` | Per-order log lines |
|
|
125
45
|
|
|
126
|
-
##
|
|
46
|
+
## Notes
|
|
127
47
|
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
- Reads the order header from `data-widget="titleWithTimer"` and parses `orderDate` in `YYYY-MM-DD` (UTC).
|
|
132
|
-
- Waits for `shipmentWidget` or `titleWithTimer` before declaring a missing order (logs show wait duration in verbose mode).
|
|
133
|
-
- Stops at the first in-progress or missing order.
|
|
134
|
-
- When backend upload is enabled, submits items per order using `orderNumber` as the backend `orderId` plus the `userId` field.
|
|
135
|
-
- The backend also downloads each item's `imageUrl`, stores it under `backend/photos/`, and replaces the stored value with that relative path; use `POST /photos/download` to refresh older rows that still reference remote URLs.
|
|
48
|
+
- The Chrome profile (`chrome-profile/` by default) carries your Ozon cookies. Don't share it.
|
|
49
|
+
- First navigation can hit the Ozon anti-bot challenge — the CLI auto-retries `Navigation timeout` up to three times.
|
|
50
|
+
- `--no-backend` outputs JSON to `--output` (or stdout) and skips submission. Useful for offline parsing.
|
|
136
51
|
|
|
137
|
-
##
|
|
52
|
+
## License
|
|
138
53
|
|
|
139
|
-
|
|
140
|
-
- DevTools connection error: ensure Chrome is started with `--remote-debugging-port=9222`.
|
|
54
|
+
MIT
|
package/dist/index.d.ts
ADDED