This repository was archived by the owner on Feb 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathowhat.py
More file actions
74 lines (59 loc) · 2.21 KB
/
Copy pathowhat.py
File metadata and controls
74 lines (59 loc) · 2.21 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import urllib.request, urllib
import requests
import time
import string,json
raiseID = 67655
def getOwhatRankingList(raiseID,page):
headers = {
'host':'m.owhat.cn',
'content-type':'application/x-www-form-urlencoded'
}
params = {
'cmd_s': 'shop.goods',
'cmd_m': 'findrankingbygoodsid',
'v': '5.5.0',
'client': '{"platform":"mobile", "version":"5.5.0", "deviceid":"xyz", "channel":"owhat"}',
'data': '{ "goodsid":"'+ str(raiseID) +'", "pagenum":'+str(page)+', "pagesize":20 }'
}
url = "https://m.owhat.cn/api?requesttimestap=" + str(int(time.time()*1000))
response = requests.post(url,params,json=True,headers=headers)
print(url)
resJsonData = response.json()
rankingList = resJsonData['data']['rankinglist']
resultList = []
for thisItem in rankingList:
resultList.append(rankingModel(thisItem['nickname'],thisItem['number'],thisItem['userid'],thisItem['amount']))
return resultList
def getOwhatSales(raiseID):
headers = {
'host':'m.owhat.cn',
'content-type':'application/x-www-form-urlencoded'
}
params = {
'cmd_s': 'shop.price',
'cmd_m': 'findPricesAndStock',
'v': '5.5.0',
'client': '{"platform":"mobile", "version":"5.5.0", "deviceid":"xyz", "channel":"owhat"}',
'data': '{ "fk_goods_id":"'+str(raiseID)+'"}'
}
url = "https://m.owhat.cn/api?requesttimestap=" + str(int(time.time()*1000))
response = requests.post(url,params,json=True,headers=headers)
print(url)
resJsonData = response.json()
rankingList = resJsonData['data']['prices']
resultList = []
for thisItem in rankingList:
resultList.append(rankingModel(thisItem['name'],thisItem['price'],thisItem['salestock'],thisItem['remainstock']))
return resultList
class rankingModel(object):
def __init__(self,nickname,rank,userid,amount):
self.nickname = nickname
self.rank = rank
self.userid = userid
self.amount = amount
class salesModel(object):
def __init__(self,name,price,salestock,remainstock):
self.name = name
self.price = price
self.salestock = salestock
self.remainstock = remainstock