forked from chendayin/taobao_spider
-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_item_real_price.py
37 lines (32 loc) · 1 KB
/
get_item_real_price.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from root_api import gw_api
from utlis import *
from get_item_skuId import get_sku_id
import re
import time
US_URL = "http://106.53.51.241:2779/queryUser"
C_URL = "http://192.168.79.38:2778/queryCookie"
def get_price(item_id):
sku_id = get_sku_id(item_id)
if sku_id:
data = r'{"itemId":"%s","skuId":"%s"}' % (item_id, sku_id)
version = "4.0"
api = "mtop.trade.order.build"
host = "trade-acs.m.taobao.com"
sid, uid = get_sid_uid(US_URL)
r = gw_api(api, version, data, host, uid=uid, sid=sid, method="POST")
try:
price = eval(re.findall(r'"orderPay_.*?"price":(.+?").*?', r)[0])
return price
except:
print("----" * 10)
print(r)
print("----" * 10)
print(item_id)
print("----" * 10)
else:
print("该商品没有sku_id")
if __name__ == '__main__':
t = time.time()
p = get_price("623747744327")
print(p)
print(f"cost time {time.time() - t}s")