70 lines
2.1 KiB
Python
70 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Extract and inspect __NEXT_DATA__ from a cached lot page"""
|
|
import sqlite3
|
|
import zlib
|
|
import json
|
|
import re
|
|
|
|
conn = sqlite3.connect('/mnt/okcomputer/output/cache.db')
|
|
|
|
# Get a cached auction page
|
|
cursor = conn.execute("""
|
|
SELECT url, content
|
|
FROM cache
|
|
WHERE url LIKE '%/a/%'
|
|
LIMIT 1
|
|
""")
|
|
|
|
row = cursor.fetchone()
|
|
if not row:
|
|
print("No cached lot pages found")
|
|
exit(1)
|
|
|
|
url, content_blob = row
|
|
print(f"Inspecting: {url}\n")
|
|
|
|
# Decompress
|
|
content = zlib.decompress(content_blob).decode('utf-8')
|
|
|
|
# Extract __NEXT_DATA__
|
|
match = re.search(r'<script[^>]*id="__NEXT_DATA__"[^>]*>(.+?)</script>', content, re.DOTALL)
|
|
if not match:
|
|
print("No __NEXT_DATA__ found")
|
|
exit(1)
|
|
|
|
data = json.loads(match.group(1))
|
|
page_props = data.get('props', {}).get('pageProps', {})
|
|
|
|
if 'auction' in page_props:
|
|
auction = page_props['auction']
|
|
print("AUCTION DATA STRUCTURE:")
|
|
print("=" * 60)
|
|
print(f"displayId: {auction.get('displayId')}")
|
|
print(f"name: {auction.get('name', '')[:50]}...")
|
|
print(f"lots count: {len(auction.get('lots', []))}")
|
|
|
|
if auction.get('lots'):
|
|
lot = auction['lots'][0]
|
|
print(f"\nFIRST LOT STRUCTURE:")
|
|
print(f" displayId: {lot.get('displayId')}")
|
|
print(f" title: {lot.get('title', '')[:50]}...")
|
|
print(f"\n BIDDING:")
|
|
print(f" currentBid: {lot.get('currentBid')}")
|
|
print(f" highestBid: {lot.get('highestBid')}")
|
|
print(f" startingBid: {lot.get('startingBid')}")
|
|
print(f" minimumBidAmount: {lot.get('minimumBidAmount')}")
|
|
print(f" bidCount: {lot.get('bidCount')}")
|
|
print(f" numberOfBids: {lot.get('numberOfBids')}")
|
|
print(f" TIMING:")
|
|
print(f" endDate: {lot.get('endDate')}")
|
|
print(f" startDate: {lot.get('startDate')}")
|
|
print(f" closingTime: {lot.get('closingTime')}")
|
|
print(f" ALL KEYS: {list(lot.keys())}")
|
|
|
|
print(f"\nAUCTION TIMING:")
|
|
print(f" minEndDate: {auction.get('minEndDate')}")
|
|
print(f" maxEndDate: {auction.get('maxEndDate')}")
|
|
print(f" ALL KEYS: {list(auction.keys())}")
|
|
|
|
conn.close()
|