enrichment
This commit is contained in:
21
src/parse.py
21
src/parse.py
@@ -109,7 +109,8 @@ class DataParser:
|
||||
page_props = data.get('props', {}).get('pageProps', {})
|
||||
|
||||
if 'lot' in page_props:
|
||||
return self._parse_lot_json(page_props.get('lot', {}), url)
|
||||
# Pass both lot and auction data (auction is included in lot pages)
|
||||
return self._parse_lot_json(page_props.get('lot', {}), url, page_props.get('auction'))
|
||||
if 'auction' in page_props:
|
||||
return self._parse_auction_json(page_props.get('auction', {}), url)
|
||||
return None
|
||||
@@ -118,8 +119,14 @@ class DataParser:
|
||||
print(f" → Error parsing __NEXT_DATA__: {e}")
|
||||
return None
|
||||
|
||||
def _parse_lot_json(self, lot_data: Dict, url: str) -> Dict:
|
||||
"""Parse lot data from JSON"""
|
||||
def _parse_lot_json(self, lot_data: Dict, url: str, auction_data: Optional[Dict] = None) -> Dict:
|
||||
"""Parse lot data from JSON
|
||||
|
||||
Args:
|
||||
lot_data: Lot object from __NEXT_DATA__
|
||||
url: Page URL
|
||||
auction_data: Optional auction object (included in lot pages)
|
||||
"""
|
||||
location_data = lot_data.get('location', {})
|
||||
city = location_data.get('city', '')
|
||||
country = location_data.get('countryCode', '').upper()
|
||||
@@ -145,10 +152,16 @@ class DataParser:
|
||||
category = lot_data.get('category', {})
|
||||
category_name = category.get('name', '') if isinstance(category, dict) else ''
|
||||
|
||||
# Get auction displayId from auction data if available (lot pages include auction)
|
||||
# Otherwise fall back to the UUID auctionId
|
||||
auction_id = lot_data.get('auctionId', '')
|
||||
if auction_data and auction_data.get('displayId'):
|
||||
auction_id = auction_data.get('displayId')
|
||||
|
||||
return {
|
||||
'type': 'lot',
|
||||
'lot_id': lot_data.get('displayId', ''),
|
||||
'auction_id': lot_data.get('auctionId', ''),
|
||||
'auction_id': auction_id,
|
||||
'url': url,
|
||||
'title': lot_data.get('title', ''),
|
||||
'current_bid': current_bid_str,
|
||||
|
||||
Reference in New Issue
Block a user