-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_scraper.py
More file actions
57 lines (46 loc) · 1.76 KB
/
test_scraper.py
File metadata and controls
57 lines (46 loc) · 1.76 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""Prueba del scraper"""
from oreillyauto_scraper import OReillyAutoScraper
import json
import time
scraper = OReillyAutoScraper()
# URL de prueba con muchas specs (alternador = 20 specs)
url = "https://www.oreillyauto.com/detail/c/ultima/ultima-150-amp-alternator-remanufactured/ult0/r113735"
print("=" * 60)
print("PRUEBA SCRAPER COMPLETO")
print("=" * 60)
print(f"\nURL: {url}\n")
data = scraper.scrape_full(url)
if data["success"]:
print("--- INFO BASICA ---")
print(f"Nombre: {data['name']}")
print(f"SKU: {data['sku']}")
print(f"MPN: {data['mpn']}")
print(f"LineCode: {data['lineCode']}")
print(f"ItemNumber: {data['itemNumber']}")
print("\n--- PRECIOS ---")
print(f"Precio: ${data['pricing']['price']}")
print(f"Retail: ${data['pricing']['retailPrice']}")
print(f"Sale: ${data['pricing']['salePrice']}")
print(f"En oferta: {data['pricing']['onSale']}")
print("\n--- DISPONIBILIDAD ---")
print(f"Pickup: {data['availability']['availPickup']}")
print(f"En tienda: {data['availability']['inStoreNow']}")
print(f"Envio: {data['availability']['availShip']}")
print("\n--- REVIEWS ---")
if data.get("reviews"):
print(f"Count: {data['reviews']['count']}")
print(f"Average: {data['reviews']['average']}")
else:
print("Sin reviews")
print("\n--- IMAGENES ---")
print(f"Primary: {data['images']['primary']}")
print(f"PrimaryXL: {data['images']['primaryXL']}")
print(f"\n--- SPECS ({len(data.get('specs', {}))}) ---")
for k, v in data.get("specs", {}).items():
print(f" {k}: {v}")
# Guardar JSON
with open("test_result.json", "w") as f:
json.dump(data, f, indent=2)
print("\nGuardado en test_result.json")
else:
print(f"ERROR: {data.get('error')}")