From e21de423b12814e78afeb21da62d0bbe1d3b7e22 Mon Sep 17 00:00:00 2001 From: hoelee Date: Wed, 9 Sep 2026 05:41:14 +0800 Subject: [PATCH] Exclude Carousell ads; fix thumbnail suffix strip for extension-less URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fetch_listings 跳过 listingID=0 的广告卡片(title 常为 ap_promo_*) - strip_thumbnail_suffix 改用 replace,同时覆盖 _progressive_thumbnail.jpg 和 _progressive_thumbnail(无扩展名)两种形态 --- monitor.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index c20ee5d..5aa758c 100644 --- a/monitor.py +++ b/monitor.py @@ -58,10 +58,15 @@ SELLER_URL_TMPL = "https://www.carousell.com.my/u/{username}/" def strip_thumbnail_suffix(url): - """去掉 Carousell 缩略图后缀 _progressive_thumbnail,得到高清原图 URL。""" + """去掉 Carousell 缩略图后缀 _progressive_thumbnail,得到高清原图 URL。 + + 两种形态都去掉: + 1) ..._progressive_thumbnail.jpg → ...jpg + 2) ..._progressive_thumbnail → ...(无扩展名,仍是合法 JPEG) + """ if not url: return url - return re.sub(r"_progressive_thumbnail(?=\.\w+$)", "", url) + return url.replace("_progressive_thumbnail", "") # Column definitions: table title -> list of (title, uidt) LISTINGS_COLS = [ @@ -250,6 +255,9 @@ def fetch_listings(search_url): for c in cards: try: lid = int(c["listingID"]) + # 广告卡片:listingID=0(title 常为 ap_promo_*),跳过不归档 + if lid == 0: + continue # 上架时间优先取 time_created;被顶置(bump)的商品只提供 # active_bump 时间戳,fallback 到它。两者结构相同(timestampContent)。 ts = None