diff --git a/platform/py-monitor/monitor_core/urls.py b/platform/py-monitor/monitor_core/urls.py new file mode 100644 index 00000000..df59d00b --- /dev/null +++ b/platform/py-monitor/monitor_core/urls.py @@ -0,0 +1,19 @@ +"""Listing URL normalisation.""" + +import urllib.parse + +PRODUCT_URL_TMPL = "https://www.carousell.com.my/p/{listing_id}/" + + +def strip_thumbnail_suffix(url): + """去掉 Carousell 缩略图后缀 _progressive_thumbnail,得到高清原图 URL。 + + 两种形态都去掉: + 1) ..._progressive_thumbnail.jpg → ...jpg + 2) ..._progressive_thumbnail → ...(无扩展名,仍是合法 JPEG) + """ + if not url: + return url + return url.replace("_progressive_thumbnail", "") + +