feat(py-monitor): add strip_thumbnail_suffix()
This commit is contained in:
1 parent
067387baee
commit
91593210e8
1 file changed
+19
@@ -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", "")
|
||||
|
||||
|
||||
Reference in new issue
Block a user