Răsfoiți Sursa

fix(wheatland): 规范竞拍价格字段格式和清理调试代码

- 解析竞拍数据时提取 min_bid 和 final_price 字段
- 移除价格字段中的美元符号和千位分隔符逗号
- 保证当字段为空时返回空字符串
- 注释掉测试时使用的主程序入口代码,避免执行干扰
charley 1 săptămână în urmă
părinte
comite
428906b5ef
1 a modificat fișierele cu 7 adăugiri și 4 ștergeri
  1. 7 4
      wheatland_spider/wheatland_core.py

+ 7 - 4
wheatland_spider/wheatland_core.py

@@ -209,6 +209,8 @@ def parse_search_grid(selector, auction_id, auction_name):
         lot_href = tds[1].css('a::attr(href)').get() or ""
         inventory_id = parse_inventory_id(lot_href)
         detail_url = urljoin(BASE_URL, lot_href) if lot_href else ""
+        min_bid = tds[3].xpath('./text()').get() or ""
+        final_price = tds[4].xpath('normalize-space(.)').get() or ""
 
         rows.append({
             "auction_id": auction_id,  # 场次 id
@@ -216,11 +218,12 @@ def parse_search_grid(selector, auction_id, auction_name):
             "lot_number": tds[1].xpath('normalize-space(.)').get() or "",  # 第 2 列 Lot Number
             "inventory_id": inventory_id,  # 从 LotDetail 链接抽出
             "title": tds[2].xpath('normalize-space(.)').get() or "",  # 第 3 列 Title
-            "min_bid": tds[3].xpath('normalize-space(.)').get() or "",  # 第 4 列 Min Bid
-            "final_price": tds[4].xpath('normalize-space(.)').get() or "",  # 第 5 列 Final Price
+            "min_bid": min_bid.replace('$', '').replace(',', '') if min_bid else "",  # 第 4 列 Min Bid
+            "final_price": final_price.replace('$', '').replace(',', '') if final_price else "",  # 第 5 列 Final Price
             "status": tds[5].xpath('normalize-space(.)').get() or "",  # 第 6 列 Status
             "detail_url": detail_url,  # 详情绝对 URL
         })
+        # print(rows)
     return rows
 
 
@@ -397,5 +400,5 @@ def update_details_for_pending(log, sql_pool):
             )
 
 
-if __name__ == '__main__':
-    get_details(logger,'https://wheatlandauctionservices.com/LotDetail.aspx?inventoryid=15233', None, 1)
+# if __name__ == '__main__':
+#     get_details(logger,'https://wheatlandauctionservices.com/LotDetail.aspx?inventoryid=15233', None, 1)