Files
mini_code/test1.py

32 lines
958 B
Python
Raw Normal View History

2025-12-15 14:54:55 +08:00
import requests
2025-12-15 15:50:35 +08:00
import uuid
2025-12-15 14:54:55 +08:00
2025-12-15 15:50:35 +08:00
session = requests.Session()
2025-12-15 14:54:55 +08:00
headers = {
2025-12-15 15:50:35 +08:00
"User-Agent": "ShopeeApp/3.54.2 (Android 13; SM-G991B)", # 新版本 UA
"Accept": "application/json",
"Accept-Language": "id-ID",
"X-Requested-With": "com.shopee.id",
"Referer": "https://shopee.co.id/",
"Connection": "keep-alive",
"X-Shopee-Device-Id": str(uuid.uuid4()), # 每次请求随机 device_id
2025-12-15 14:54:55 +08:00
}
2025-12-15 15:50:35 +08:00
def get_item(itemid, shopid):
url = "https://shopee.co.id/api/v4/item/get"
params = {"itemid": itemid, "shopid": shopid}
r = session.get(url, headers=headers, params=params, timeout=10)
r.raise_for_status()
return r.json()
2025-12-15 14:54:55 +08:00
2025-12-15 15:50:35 +08:00
if __name__ == "__main__":
data = get_item(4420309814, 10115139)
item = data.get("data", {}).get("item")
if item:
print("商品名:", item["name"])
print("价格:", item["price"] // 100000)
print("库存:", item["stock"])
else:
print("无数据 / 被风控")