-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.py
More file actions
37 lines (29 loc) · 1.16 KB
/
quickstart.py
File metadata and controls
37 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Quickstart: pull a few products from a single WooCommerce store.
pip install -r requirements.txt
export APIFY_API_TOKEN=apify_api_xxxxxx
python examples/quickstart.py
"""
from woocommerce_scraper import WooCommerceScraperClient
def main() -> None:
client = WooCommerceScraperClient()
products = client.analyze_store(
"https://woocommerce.com",
max_products=10,
enrich_variants=True,
)
print(f"\nGot {len(products)} products\n")
for p in products[:5]:
print(f"=== {p.get('title')} ===")
print(f" Price: {p.get('price')} {p.get('currency')}")
if p.get("discountPct"):
print(f" Discount: {p.get('discountPct')}%")
print(f" Brand: {p.get('brand') or '(unknown)'}")
print(f" Category: {p.get('autoCategory')}")
print(f" Rank: #{p.get('popularityRank')}")
print(f" Score: {p.get('productIntelligenceScore')}/100")
print(f" In stock: {p.get('inStock')}")
print(f" New arrival: {p.get('isNewArrival')}")
print()
if __name__ == "__main__":
main()