32 lines
958 B
Python
32 lines
958 B
Python
import requests
|
|
import uuid
|
|
|
|
session = requests.Session()
|
|
|
|
headers = {
|
|
"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
|
|
}
|
|
|
|
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()
|
|
|
|
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("无数据 / 被风控")
|