wb-sdk-pro 2.1.1__py3-none-any.whl
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.
- wb_parser/__init__.py +95 -0
- wb_parser/cli.py +324 -0
- wb_parser/client.py +777 -0
- wb_parser/config.py +97 -0
- wb_parser/exceptions.py +48 -0
- wb_parser/export.py +293 -0
- wb_parser/gui/__init__.py +21 -0
- wb_parser/gui/app.py +1179 -0
- wb_parser/http.py +399 -0
- wb_parser/mcp_server.py +381 -0
- wb_parser/models.py +280 -0
- wb_parser/py.typed +1 -0
- wb_parser/rank.py +203 -0
- wb_parser/reviews.py +307 -0
- wb_parser/shards.py +305 -0
- wb_parser/telegram.py +100 -0
- wb_parser/tracker.py +190 -0
- wb_parser/wallet.py +169 -0
- wb_sdk_pro-2.1.1.dist-info/METADATA +217 -0
- wb_sdk_pro-2.1.1.dist-info/RECORD +22 -0
- wb_sdk_pro-2.1.1.dist-info/WHEEL +4 -0
- wb_sdk_pro-2.1.1.dist-info/entry_points.txt +5 -0
wb_parser/__init__.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Wildberries Parser SDK & Desktop GUI (`wb_parser`).
|
|
3
|
+
|
|
4
|
+
Modular Python SDK + CLI + Native MCP Server + CustomTkinter Desktop GUI
|
|
5
|
+
for Wildberries card inspection, dynamic basket-01..65+ routing, sharded
|
|
6
|
+
feedback collection (`feedbacks1` / `feedbacks2`), price tracking, and Excel export.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
__version__ = "2.1.1"
|
|
12
|
+
|
|
13
|
+
from wb_parser.client import AsyncWBClient, ParseWB, WBClient, filter_products
|
|
14
|
+
from wb_parser.config import DEST_CODES, DEFAULT_DEST, WBConfig
|
|
15
|
+
from wb_parser.exceptions import (
|
|
16
|
+
WBAntiBotError,
|
|
17
|
+
WBError,
|
|
18
|
+
WBNetworkError,
|
|
19
|
+
WBNotFoundError,
|
|
20
|
+
WBRateLimitError,
|
|
21
|
+
WBValidationError,
|
|
22
|
+
)
|
|
23
|
+
from wb_parser.export import rank_results_to_excel, to_csv, to_dataframe, to_excel, to_json, to_jsonl
|
|
24
|
+
from wb_parser.models import (
|
|
25
|
+
Feedback,
|
|
26
|
+
FeedbackInfo,
|
|
27
|
+
Item,
|
|
28
|
+
Items,
|
|
29
|
+
PriceRecord,
|
|
30
|
+
WBProduct,
|
|
31
|
+
WBSearchPage,
|
|
32
|
+
)
|
|
33
|
+
from wb_parser.rank import RankResult, WBRankTracker
|
|
34
|
+
from wb_parser.reviews import ReviewItem, ReviewSummary, SmartReviewAnalyzer
|
|
35
|
+
from wb_parser.shards import (
|
|
36
|
+
DEFAULT_BASKET_RANGES,
|
|
37
|
+
BasketRoute,
|
|
38
|
+
BasketRouter,
|
|
39
|
+
calculate_feedback_shard,
|
|
40
|
+
classify_target,
|
|
41
|
+
extract_nm_id,
|
|
42
|
+
extract_seller_id,
|
|
43
|
+
feedback_url,
|
|
44
|
+
)
|
|
45
|
+
from wb_parser.telegram import TelegramNotifier
|
|
46
|
+
from wb_parser.tracker import WBPriceTracker
|
|
47
|
+
from wb_parser.wallet import WBWalletCalculator, WalletPriceResult, WalletSettings
|
|
48
|
+
|
|
49
|
+
__all__ = [
|
|
50
|
+
"__version__",
|
|
51
|
+
"AsyncWBClient",
|
|
52
|
+
"BasketRoute",
|
|
53
|
+
"BasketRouter",
|
|
54
|
+
"DEFAULT_BASKET_RANGES",
|
|
55
|
+
"DEFAULT_DEST",
|
|
56
|
+
"DEST_CODES",
|
|
57
|
+
"Feedback",
|
|
58
|
+
"FeedbackInfo",
|
|
59
|
+
"Item",
|
|
60
|
+
"Items",
|
|
61
|
+
"ParseWB",
|
|
62
|
+
"PriceRecord",
|
|
63
|
+
"RankResult",
|
|
64
|
+
"ReviewItem",
|
|
65
|
+
"ReviewSummary",
|
|
66
|
+
"SmartReviewAnalyzer",
|
|
67
|
+
"TelegramNotifier",
|
|
68
|
+
"WBAntiBotError",
|
|
69
|
+
"WBClient",
|
|
70
|
+
"WBConfig",
|
|
71
|
+
"WBError",
|
|
72
|
+
"WBNetworkError",
|
|
73
|
+
"WBNotFoundError",
|
|
74
|
+
"WBPriceTracker",
|
|
75
|
+
"WBProduct",
|
|
76
|
+
"WBRankTracker",
|
|
77
|
+
"WBRateLimitError",
|
|
78
|
+
"WBSearchPage",
|
|
79
|
+
"WBValidationError",
|
|
80
|
+
"WBWalletCalculator",
|
|
81
|
+
"WalletPriceResult",
|
|
82
|
+
"WalletSettings",
|
|
83
|
+
"calculate_feedback_shard",
|
|
84
|
+
"classify_target",
|
|
85
|
+
"extract_nm_id",
|
|
86
|
+
"extract_seller_id",
|
|
87
|
+
"feedback_url",
|
|
88
|
+
"filter_products",
|
|
89
|
+
"rank_results_to_excel",
|
|
90
|
+
"to_csv",
|
|
91
|
+
"to_dataframe",
|
|
92
|
+
"to_excel",
|
|
93
|
+
"to_json",
|
|
94
|
+
"to_jsonl",
|
|
95
|
+
]
|
wb_parser/cli.py
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command-Line Interface (CLI) for Wildberries Parser SDK (`wb-parser` / `wb-sdk`).
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import json
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import List, Optional
|
|
12
|
+
|
|
13
|
+
from wb_parser import __version__
|
|
14
|
+
from wb_parser.client import WBClient, filter_products
|
|
15
|
+
from wb_parser.config import DEFAULT_DEST, DEST_CODES, DOCS_URL, ISSUES_URL, TELEGRAM_CHANNEL_URL
|
|
16
|
+
from wb_parser.export import rank_results_to_excel, to_csv, to_excel, to_json, to_jsonl
|
|
17
|
+
from wb_parser.models import WBProduct
|
|
18
|
+
from wb_parser.shards import calculate_feedback_shard, extract_nm_id
|
|
19
|
+
from wb_parser.tracker import WBPriceTracker
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _export_results(products: List[WBProduct], output_path: Optional[str]) -> None:
|
|
23
|
+
if not output_path:
|
|
24
|
+
return
|
|
25
|
+
path = Path(output_path)
|
|
26
|
+
ext = path.suffix.lower()
|
|
27
|
+
if ext == ".xlsx":
|
|
28
|
+
to_excel(products, path)
|
|
29
|
+
elif ext == ".csv":
|
|
30
|
+
to_csv(products, path)
|
|
31
|
+
elif ext == ".jsonl":
|
|
32
|
+
to_jsonl(products, path)
|
|
33
|
+
else:
|
|
34
|
+
to_json(products, path)
|
|
35
|
+
print(f"[+] Exported {len(products)} item(s) -> {path}")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _print_products_table(products: List[WBProduct]) -> None:
|
|
39
|
+
if not products:
|
|
40
|
+
print("No products found.")
|
|
41
|
+
return
|
|
42
|
+
for idx, p in enumerate(products, start=1):
|
|
43
|
+
price_str = f"{p.price:,.0f} RUB" if p.price > 0 else "CDN (no live price)"
|
|
44
|
+
disc_str = f" (-{p.discount}%)" if p.discount > 0 else ""
|
|
45
|
+
fb_str = f" | ★ {p.valuation or p.rating} ({p.feedback_count} reviews)" if (p.feedback_count or p.rating) else ""
|
|
46
|
+
print(f"{idx:2d}. [{p.id}] {p.name[:60]} | {p.brand or '-'} | {price_str}{disc_str}{fb_str}")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _build_client(args: argparse.Namespace) -> WBClient:
|
|
50
|
+
dest_val = getattr(args, "dest", DEFAULT_DEST)
|
|
51
|
+
if isinstance(dest_val, str) and dest_val in DEST_CODES:
|
|
52
|
+
dest_val = DEST_CODES[dest_val]
|
|
53
|
+
return WBClient(
|
|
54
|
+
dest=int(dest_val),
|
|
55
|
+
proxy=getattr(args, "proxy", None),
|
|
56
|
+
proxy_change_url=getattr(args, "proxy_change_url", None),
|
|
57
|
+
cookies=getattr(args, "cookies", None),
|
|
58
|
+
wbaas_token=getattr(args, "wbaas_token", None),
|
|
59
|
+
tracker_db=getattr(args, "db", None),
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _add_network_args(subparser: argparse.ArgumentParser) -> None:
|
|
64
|
+
subparser.add_argument("--dest", default=str(DEFAULT_DEST), help="WB region destination ID or city name")
|
|
65
|
+
subparser.add_argument("--proxy", default=None, help="Proxy URL (http://user:pass@ip:port or socks5://...)")
|
|
66
|
+
subparser.add_argument("--proxy-change-url", default=None, help="Mobile proxy rotation URL")
|
|
67
|
+
subparser.add_argument("--cookies", default=None, help="Optional browser Cookie header string")
|
|
68
|
+
subparser.add_argument("--wbaas-token", default=None, help="Optional x-wbaas-token header")
|
|
69
|
+
subparser.add_argument("--db", default="wb_prices.db", help="SQLite price history path")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def main(argv: Optional[List[str]] = None) -> int:
|
|
73
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
74
|
+
try:
|
|
75
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
76
|
+
except Exception:
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
parser = argparse.ArgumentParser(
|
|
80
|
+
prog="wb-parser",
|
|
81
|
+
description=f"Wildberries Parser SDK v{__version__} — CDN Card Inspector, Feedback Sharder, Search & GUI",
|
|
82
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
83
|
+
epilog=(
|
|
84
|
+
f"Telegram Support: {TELEGRAM_CHANNEL_URL}\n"
|
|
85
|
+
f"Docs: {DOCS_URL}\n"
|
|
86
|
+
f"Issues: {ISSUES_URL}"
|
|
87
|
+
),
|
|
88
|
+
)
|
|
89
|
+
parser.add_argument("-V", "--version", action="version", version=f"%(prog)s {__version__}")
|
|
90
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
91
|
+
|
|
92
|
+
# 1. card
|
|
93
|
+
card_p = subparsers.add_parser("card", help="Fetch single product card (CDN card.json + feedbacks1/2)")
|
|
94
|
+
card_p.add_argument("target", help="Wildberries product URL or numeric article (nm_id)")
|
|
95
|
+
card_p.add_argument("--no-feedbacks", action="store_true", help="Skip feedbacks1/2 request")
|
|
96
|
+
card_p.add_argument("--history", action="store_true", help="Include CDN price-history.json")
|
|
97
|
+
card_p.add_argument("-o", "--output", help="Save output (.json, .jsonl, .csv, .xlsx)")
|
|
98
|
+
_add_network_args(card_p)
|
|
99
|
+
|
|
100
|
+
# 2. feedbacks
|
|
101
|
+
fb_p = subparsers.add_parser("feedbacks", help="Fetch sharded reviews from feedbacks1/2 using root_id or nm_id")
|
|
102
|
+
fb_p.add_argument("target", help="Root ID (imt_id) OR product URL / nm_id (use --is-nm)")
|
|
103
|
+
fb_p.add_argument("--is-nm", action="store_true", help="Resolve nm_id -> root_id via CDN card.json first")
|
|
104
|
+
_add_network_args(fb_p)
|
|
105
|
+
|
|
106
|
+
# 3. seller
|
|
107
|
+
seller_p = subparsers.add_parser("seller", help="Scrape all products for a seller URL, supplier ID, or sample item URL")
|
|
108
|
+
seller_p.add_argument("target", help="Seller URL (/seller/123), supplier ID, or product URL")
|
|
109
|
+
seller_p.add_argument("-p", "--pages", type=int, default=5, help="Max catalog pages")
|
|
110
|
+
seller_p.add_argument("-n", "--limit", type=int, default=200, help="Max items")
|
|
111
|
+
seller_p.add_argument("--enrich", action="store_true", help="Enrich each item with full CDN card.json specs")
|
|
112
|
+
seller_p.add_argument("--no-feedbacks", action="store_true", help="Skip feedback fetching")
|
|
113
|
+
seller_p.add_argument("-o", "--output", help="Save output (.xlsx, .csv, .json, .jsonl)")
|
|
114
|
+
_add_network_args(seller_p)
|
|
115
|
+
|
|
116
|
+
# 4. search
|
|
117
|
+
search_p = subparsers.add_parser("search", help="Search Wildberries catalog")
|
|
118
|
+
search_p.add_argument("query", help="Search keyword")
|
|
119
|
+
search_p.add_argument("-p", "--pages", type=int, default=2, help="Max pages")
|
|
120
|
+
search_p.add_argument("-n", "--limit", type=int, default=50, help="Max items")
|
|
121
|
+
search_p.add_argument("--min-price", type=int, default=0, help="Minimum price filter (RUB)")
|
|
122
|
+
search_p.add_argument("--max-price", type=int, default=999_999_999, help="Maximum price filter (RUB)")
|
|
123
|
+
search_p.add_argument("--min-discount", type=int, default=0, help="Minimum discount percentage")
|
|
124
|
+
search_p.add_argument("--min-rating", type=float, default=0.0, help="Minimum rating filter")
|
|
125
|
+
search_p.add_argument("--enrich", action="store_true", help="Enrich with CDN card.json specs")
|
|
126
|
+
search_p.add_argument("--with-feedbacks", action="store_true", help="Fetch sharded reviews")
|
|
127
|
+
search_p.add_argument("-o", "--output", help="Save output (.xlsx, .csv, .json, .jsonl)")
|
|
128
|
+
_add_network_args(search_p)
|
|
129
|
+
|
|
130
|
+
# 5. drops
|
|
131
|
+
drops_p = subparsers.add_parser("drops", help="Show tracked price drops from SQLite")
|
|
132
|
+
drops_p.add_argument("--db", default="wb_prices.db", help="Path to SQLite tracker DB")
|
|
133
|
+
drops_p.add_argument("-n", "--limit", type=int, default=50, help="Max records")
|
|
134
|
+
|
|
135
|
+
# 6. upstreams
|
|
136
|
+
up_p = subparsers.add_parser("upstreams", help="Fetch live CDN basket shard ranges (cdn.wbbasket.ru)")
|
|
137
|
+
_add_network_args(up_p)
|
|
138
|
+
|
|
139
|
+
# 7. wallet
|
|
140
|
+
wal_p = subparsers.add_parser("wallet", help="Calculate WB Wallet discounted price for a RUB price")
|
|
141
|
+
wal_p.add_argument("price", type=float, help="Base price in RUB")
|
|
142
|
+
wal_p.add_argument("--club", action="store_true", help="Use WB Club discount tier")
|
|
143
|
+
_add_network_args(wal_p)
|
|
144
|
+
|
|
145
|
+
# 8. rank
|
|
146
|
+
rank_p = subparsers.add_parser("rank", help="Check product search position (rank) for a keyword query")
|
|
147
|
+
rank_p.add_argument("target", help="Product URL or numeric nm_id")
|
|
148
|
+
rank_p.add_argument("query", help="Search keyword query")
|
|
149
|
+
rank_p.add_argument("-p", "--pages", type=int, default=3, help="Max search pages to scan (100 items/page)")
|
|
150
|
+
rank_p.add_argument("--sort", default="popular", help="Sort order (popular, pricedown, priceup, rate)")
|
|
151
|
+
rank_p.add_argument("-o", "--output", help="Save rank report (.xlsx or .json)")
|
|
152
|
+
_add_network_args(rank_p)
|
|
153
|
+
|
|
154
|
+
# 9. reviews
|
|
155
|
+
rev_p = subparsers.add_parser("reviews", help="Smart Review Analyzer (pros/cons/size fit via CDN + feedbacks1/2)")
|
|
156
|
+
rev_p.add_argument("target", help="Product URL or numeric nm_id")
|
|
157
|
+
rev_p.add_argument("--all-colors", action="store_true", help="Analyze all linked colors (root_id) instead of single nm_id")
|
|
158
|
+
rev_p.add_argument("-n", "--limit", type=int, default=100, help="Max reviews to inspect")
|
|
159
|
+
rev_p.add_argument("--ai-key", default=None, help="Optional OpenAI-compatible API key for LLM summary")
|
|
160
|
+
rev_p.add_argument("--ai-url", default="https://api.openai.com/v1", help="OpenAI-compatible base URL")
|
|
161
|
+
rev_p.add_argument("--ai-model", default="gpt-4o-mini", help="Model name (default: gpt-4o-mini)")
|
|
162
|
+
rev_p.add_argument("-o", "--output", help="Save summary JSON file")
|
|
163
|
+
_add_network_args(rev_p)
|
|
164
|
+
|
|
165
|
+
# 10. mcp
|
|
166
|
+
mcp_p = subparsers.add_parser("mcp", help="Start native JSON-RPC 2.0 MCP Server over stdio")
|
|
167
|
+
_add_network_args(mcp_p)
|
|
168
|
+
|
|
169
|
+
# 11. gui
|
|
170
|
+
subparsers.add_parser("gui", help="Launch Dark-Themed WB SDK Pro Desktop GUI")
|
|
171
|
+
|
|
172
|
+
args = parser.parse_args(argv)
|
|
173
|
+
if not args.command:
|
|
174
|
+
parser.print_help()
|
|
175
|
+
return 0
|
|
176
|
+
|
|
177
|
+
if args.command == "gui":
|
|
178
|
+
from wb_parser.gui import main_gui
|
|
179
|
+
return main_gui()
|
|
180
|
+
|
|
181
|
+
if args.command == "mcp":
|
|
182
|
+
from wb_parser.mcp_server import WBMCPServer
|
|
183
|
+
srv = WBMCPServer(
|
|
184
|
+
proxy=args.proxy,
|
|
185
|
+
proxy_change_url=args.proxy_change_url,
|
|
186
|
+
cookies=args.cookies,
|
|
187
|
+
wbaas_token=args.wbaas_token,
|
|
188
|
+
tracker_db=args.db,
|
|
189
|
+
)
|
|
190
|
+
srv.run_stdio()
|
|
191
|
+
return 0
|
|
192
|
+
|
|
193
|
+
if args.command == "drops":
|
|
194
|
+
tracker = WBPriceTracker(args.db)
|
|
195
|
+
drops = tracker.get_price_drops(limit=args.limit)
|
|
196
|
+
if not drops:
|
|
197
|
+
print("No price drops recorded yet.")
|
|
198
|
+
return 0
|
|
199
|
+
for d in drops:
|
|
200
|
+
diff = round((d.old_price or 0) - d.price, 2)
|
|
201
|
+
print(f"[{d.nm_id}] {d.name}: {d.price:,.0f} RUB (was {d.old_price:,.0f}, -{diff:,.0f} RUB)")
|
|
202
|
+
return 0
|
|
203
|
+
|
|
204
|
+
with _build_client(args) as client:
|
|
205
|
+
if args.command == "upstreams":
|
|
206
|
+
ping = client.ping()
|
|
207
|
+
count = client.sync_upstreams()
|
|
208
|
+
wallet_cfg = client.wallet.fetch_settings()
|
|
209
|
+
print(json.dumps({
|
|
210
|
+
"ping": ping,
|
|
211
|
+
"basket_routes": count,
|
|
212
|
+
"wallet_discount_pct": float(wallet_cfg.wallet_discount_pct),
|
|
213
|
+
"wallet_club_pct": float(wallet_cfg.club_discount_pct),
|
|
214
|
+
"wallet_max_price": float(wallet_cfg.max_price),
|
|
215
|
+
}, indent=2))
|
|
216
|
+
return 0
|
|
217
|
+
|
|
218
|
+
if args.command == "wallet":
|
|
219
|
+
res = client.wallet_price(args.price, use_club=args.club)
|
|
220
|
+
print(json.dumps({
|
|
221
|
+
"base_price": res.base_price,
|
|
222
|
+
"wallet_price": res.wallet_price,
|
|
223
|
+
"savings": res.savings,
|
|
224
|
+
"discount_pct": res.discount_pct,
|
|
225
|
+
"applied": res.applied,
|
|
226
|
+
"reason": res.reason,
|
|
227
|
+
}, indent=2))
|
|
228
|
+
return 0
|
|
229
|
+
|
|
230
|
+
if args.command == "rank":
|
|
231
|
+
res = client.check_rank(args.target, args.query, max_pages=args.pages, sort=args.sort)
|
|
232
|
+
print(res.model_dump_json(indent=2))
|
|
233
|
+
if args.output:
|
|
234
|
+
out_p = Path(args.output)
|
|
235
|
+
if out_p.suffix.lower() == ".xlsx":
|
|
236
|
+
rank_results_to_excel([res], out_p)
|
|
237
|
+
else:
|
|
238
|
+
out_p.write_text(res.model_dump_json(indent=2), encoding="utf-8")
|
|
239
|
+
print(f"[+] Exported rank report -> {out_p}")
|
|
240
|
+
return 0
|
|
241
|
+
|
|
242
|
+
if args.command == "reviews":
|
|
243
|
+
summary = client.analyze_reviews(
|
|
244
|
+
args.target,
|
|
245
|
+
only_this_color=not args.all_colors,
|
|
246
|
+
limit=args.limit,
|
|
247
|
+
ai_key=args.ai_key,
|
|
248
|
+
ai_base_url=args.ai_url,
|
|
249
|
+
ai_model=args.ai_model,
|
|
250
|
+
)
|
|
251
|
+
print(f"[{summary.nm_id}] {summary.product_name} (root={summary.root_id}, shard=feedbacks{summary.shard})")
|
|
252
|
+
print(f"Analyzed: {summary.total_analyzed} / {summary.total_available} | Avg: {summary.avg_rating} | Mode: {summary.summary_mode}")
|
|
253
|
+
if summary.size_fit:
|
|
254
|
+
print(f"Size fit: {summary.size_fit}")
|
|
255
|
+
print("Pros (+):", summary.top_pros)
|
|
256
|
+
print("Cons (-):", summary.top_cons)
|
|
257
|
+
if args.output:
|
|
258
|
+
Path(args.output).write_text(summary.model_dump_json(indent=2), encoding="utf-8")
|
|
259
|
+
print(f"[+] Saved review summary -> {args.output}")
|
|
260
|
+
return 0
|
|
261
|
+
|
|
262
|
+
if args.command == "card":
|
|
263
|
+
prod = client.get_product(
|
|
264
|
+
args.target,
|
|
265
|
+
enrich_cdn=True,
|
|
266
|
+
with_feedbacks=not args.no_feedbacks,
|
|
267
|
+
with_price_history=args.history,
|
|
268
|
+
)
|
|
269
|
+
print(prod.to_json(indent=2))
|
|
270
|
+
_export_results([prod], args.output)
|
|
271
|
+
return 0
|
|
272
|
+
|
|
273
|
+
if args.command == "feedbacks":
|
|
274
|
+
target_num = extract_nm_id(args.target)
|
|
275
|
+
if args.is_nm:
|
|
276
|
+
card = client.get_card_cdn(target_num)
|
|
277
|
+
root_id = card.root
|
|
278
|
+
else:
|
|
279
|
+
root_id = target_num
|
|
280
|
+
shard = calculate_feedback_shard(root_id)
|
|
281
|
+
fb = client.get_feedbacks(root_id)
|
|
282
|
+
if not fb:
|
|
283
|
+
print(f"No feedbacks found for root_id={root_id} (shard=feedbacks{shard})")
|
|
284
|
+
return 1
|
|
285
|
+
print(f"root_id={root_id} | server=feedbacks{fb.shard}.wb.ru (formula shard={shard})")
|
|
286
|
+
print(f"valuation={fb.valuation} | feedbackCountWithText={fb.feedback_count} | total={fb.total_feedback_count}")
|
|
287
|
+
return 0
|
|
288
|
+
|
|
289
|
+
if args.command == "seller":
|
|
290
|
+
products = client.get_seller_catalog(
|
|
291
|
+
args.target,
|
|
292
|
+
max_pages=args.pages,
|
|
293
|
+
limit=args.limit,
|
|
294
|
+
enrich_cdn=args.enrich,
|
|
295
|
+
with_feedbacks=not args.no_feedbacks,
|
|
296
|
+
)
|
|
297
|
+
_print_products_table(products)
|
|
298
|
+
_export_results(products, args.output)
|
|
299
|
+
return 0
|
|
300
|
+
|
|
301
|
+
if args.command == "search":
|
|
302
|
+
raw = client.search(
|
|
303
|
+
args.query,
|
|
304
|
+
max_pages=args.pages,
|
|
305
|
+
limit=args.limit,
|
|
306
|
+
enrich_cdn=args.enrich,
|
|
307
|
+
with_feedbacks=args.with_feedbacks,
|
|
308
|
+
)
|
|
309
|
+
products = filter_products(
|
|
310
|
+
raw,
|
|
311
|
+
min_price=args.min_price,
|
|
312
|
+
max_price=args.max_price,
|
|
313
|
+
min_discount=args.min_discount,
|
|
314
|
+
min_rating=args.min_rating,
|
|
315
|
+
)
|
|
316
|
+
_print_products_table(products)
|
|
317
|
+
_export_results(products, args.output)
|
|
318
|
+
return 0
|
|
319
|
+
|
|
320
|
+
return 0
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
if __name__ == "__main__":
|
|
324
|
+
sys.exit(main())
|