49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Find an auction page with lots data"""
|
|
import sqlite3
|
|
import zlib
|
|
import json
|
|
import re
|
|
|
|
conn = sqlite3.connect('/mnt/okcomputer/output/cache.db')
|
|
|
|
cursor = conn.execute("""
|
|
SELECT url, content
|
|
FROM cache
|
|
WHERE url LIKE '%/a/%'
|
|
""")
|
|
|
|
for row in cursor:
|
|
url, content_blob = row
|
|
content = zlib.decompress(content_blob).decode('utf-8')
|
|
|
|
match = re.search(r'<script[^>]*id="__NEXT_DATA__"[^>]*>(.+?)</script>', content, re.DOTALL)
|
|
if not match:
|
|
continue
|
|
|
|
data = json.loads(match.group(1))
|
|
page_props = data.get('props', {}).get('pageProps', {})
|
|
|
|
if 'auction' in page_props:
|
|
auction = page_props['auction']
|
|
lots = auction.get('lots', [])
|
|
|
|
if lots and len(lots) > 0:
|
|
print(f"Found auction with {len(lots)} lots: {url}\n")
|
|
|
|
lot = lots[0]
|
|
print(f"SAMPLE LOT FROM AUCTION.LOTS[]:")
|
|
print(f" displayId: {lot.get('displayId')}")
|
|
print(f" title: {lot.get('title', '')[:50]}...")
|
|
print(f" urlSlug: {lot.get('urlSlug')}")
|
|
print(f"\nBIDDING FIELDS:")
|
|
for key in ['currentBid', 'highestBid', 'startingBid', 'minimumBidAmount', 'bidCount', 'numberOfBids']:
|
|
print(f" {key}: {lot.get(key)}")
|
|
print(f"\nTIMING FIELDS:")
|
|
for key in ['endDate', 'startDate', 'closingTime']:
|
|
print(f" {key}: {lot.get(key)}")
|
|
print(f"\nALL KEYS: {list(lot.keys())[:30]}...")
|
|
break
|
|
|
|
conn.close()
|