feat(clone-app): scrape screenshots, feature graphic, description from Play
This commit is contained in:
parent
e3a29974f4
commit
aad064d220
|
|
@ -7,7 +7,8 @@ Falls back to light regex for installs/updated which aren't always in ld+json.
|
|||
import sys, json, re, argparse, urllib.request, ssl, subprocess, shutil
|
||||
|
||||
KEYS = ["package", "title", "rating", "rating_count", "installs",
|
||||
"category", "developer", "updated", "source"]
|
||||
"category", "developer", "updated", "source",
|
||||
"screenshot_urls", "feature_graphic", "description"]
|
||||
|
||||
UA = "Mozilla/5.0"
|
||||
|
||||
|
|
@ -61,6 +62,21 @@ def parse(html, package):
|
|||
if ar.get("ratingCount") is not None:
|
||||
try: out["rating_count"] = int(ar["ratingCount"])
|
||||
except Exception: pass
|
||||
out["description"] = data.get("description")
|
||||
img = data.get("image")
|
||||
if isinstance(img, list):
|
||||
img = img[0] if img else None
|
||||
out["feature_graphic"] = img
|
||||
shots = data.get("screenshot") or []
|
||||
if isinstance(shots, dict):
|
||||
shots = [shots]
|
||||
urls = []
|
||||
for s in shots:
|
||||
if isinstance(s, str):
|
||||
urls.append(s)
|
||||
elif isinstance(s, dict) and s.get("url"):
|
||||
urls.append(s["url"])
|
||||
out["screenshot_urls"] = urls
|
||||
break
|
||||
|
||||
# installs (e.g. "1,000,000+"). Play wraps the count and the "Downloads"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
<script type="application/ld+json" nonce="5kflo12lNMmEYHKRtMGqHQ">
|
||||
{"@context":"https://schema.org","@type":"SoftwareApplication","name":"Example App","author":{"name":"Example Studio"},
|
||||
"aggregateRating":{"ratingValue":"4.3","ratingCount":"12873"},
|
||||
"applicationCategory":"GAME_PUZZLE"}
|
||||
"applicationCategory":"GAME_PUZZLE",
|
||||
"description":"An example puzzle app.",
|
||||
"image":"https://play-lh.googleusercontent.com/feature.png",
|
||||
"screenshot":["https://play-lh.googleusercontent.com/shot1.png","https://play-lh.googleusercontent.com/shot2.png"]}
|
||||
</script>
|
||||
</head><body>
|
||||
<div class="reAt0">Updated on</div><div class="xg1aie">Jun 1, 2026</div>
|
||||
|
|
|
|||
|
|
@ -25,8 +25,12 @@ def main():
|
|||
check("installs", d["installs"] == "1,000,000+")
|
||||
check("updated", d["updated"] == "Jun 1, 2026")
|
||||
check("source", d["source"] == "google-play")
|
||||
check("description", d["description"] == "An example puzzle app.")
|
||||
check("feature_graphic", d["feature_graphic"] == "https://play-lh.googleusercontent.com/feature.png")
|
||||
check("screenshot count", len(d["screenshot_urls"]) == 2)
|
||||
check("screenshot url", d["screenshot_urls"][0] == "https://play-lh.googleusercontent.com/shot1.png")
|
||||
# all expected keys present even if null
|
||||
for k in ["package","title","rating","rating_count","installs","category","developer","updated","source"]:
|
||||
for k in ["package","title","rating","rating_count","installs","category","developer","updated","source","screenshot_urls","feature_graphic","description"]:
|
||||
check(f"key present: {k}", k in d)
|
||||
sys.exit(1 if fails else 0)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue