1
📥
Ambil ulasan produkAPI platform — rating, teks, pengesahan
2
🧮
Skor keaslianAnalisis NLP untuk mengesan ulasan palsu
3
🔍
Anomali & corakBurst timing, user similarity, rating deviation
4
📊
Laporan & flagIsu rating + notifikasi perlindungan
import requests, json, numpy as np
from datetime import datetime, timedelta
API_REVIEWS = "https://api.shopee.com/v2/product/reviews"
def fetch_reviews(product_id, days=30):
resp = requests.get(API_REVIEWS, params={
"product_id": product_id,
"since": (datetime.now() - timedelta(days=days)).isoformat()
})
return resp.json().get("reviews", [])
def score_authenticity(reviews):
scores = []
for r in reviews:
score = 1.0
if r.get("reviewer_tenure_days", 365) < 7:
score -= 0.3
if len(r.get("text", "")) < 20:
score -= 0.2
if r.get("rating") == 5 and r.get("has_images") == False:
score -= 0.25
scores.append({"review_id": r["id"], "score": max(0, score)})
return scores
def flag_suspicious(reviews, threshold=0.5):
scored = score_authenticity(reviews)
flagged = [s for s in scored if s["score"] < threshold]
return {
"total": len(reviews),
"flagged": len(flagged),
"suspicious_ids": [s["review_id"] for s in flagged]
}
report = flag_suspicious(fetch_reviews("PROD-001"))
print(json.dumps(report, indent=2))