feat(ai-studio): read shopee source image urls

This commit is contained in:
chengma
2026-07-11 12:24:22 +08:00
parent 5ada8af2b5
commit 10a28c1e77
6 changed files with 518 additions and 5 deletions
+22
View File
@@ -803,6 +803,22 @@ def read_cover_src(cdp) -> str:
return cdp.val(JS_FIRST_COVER) or ""
def read_product_image_urls(cdp):
"""Read all current Shopee product image URLs in page order."""
images = []
for position, rect in enumerate(_image_rects(cdp), start=1):
src = str((rect or {}).get("src") or "").strip()
if not src:
continue
try:
index = int((rect or {}).get("i", position - 1)) + 1
except (TypeError, ValueError):
index = position
images.append({"index": index, "src": src})
return images
def download_cover(src, out_path) -> str:
"""Download a cover image to a local path and return the absolute path."""
@@ -891,6 +907,12 @@ def _close_collected_product(cdp):
pass
def close_readonly_product(cdp):
"""Close a read-only product CDP session using the collection tab cleanup rules."""
_close_collected_product(cdp)
def change_title(cdp, new_title) -> dict:
"""Write a new title with the verified native setter + input/change events."""