|
@@ -33,30 +33,6 @@ def scrape(request_data, heat):
|
33
|
33
|
sp_ns = exec_time - int(time.time())
|
34
|
34
|
time.sleep(sp_ns)
|
35
|
35
|
|
36
|
|
- if heat < 2:
|
37
|
|
- goodsDb = MysqlDyLiveCommodity()
|
38
|
|
- pix = str(uid)[-1]
|
39
|
|
- goodsInfo = goodsDb.get_goods_info(room_id, product_id, pix)
|
40
|
|
-
|
41
|
|
- dataid,sold_out_at,revise_price,created_at = goodsInfo
|
42
|
|
-
|
43
|
|
- print(goodsInfo)
|
44
|
|
-
|
45
|
|
- if revise_price is not None:
|
46
|
|
- sys.exit(0)
|
47
|
|
-
|
48
|
|
-
|
49
|
|
- if sold_out_at == '0000-00-00 00:00:00' or sold_out_at == '1970-01-01 08:00:00':
|
50
|
|
- add_t = 300
|
51
|
|
- news_time = int(time.time()) + add_t
|
52
|
|
- next_rds = promotion_id + '@' + product_id + '@' + uid + '@' + room_id + '@' + str(news_time)
|
53
|
|
- rds_list.push_middle_list(next_rds)
|
54
|
|
- else :
|
55
|
|
- add_t = 1200
|
56
|
|
- news_time = int(time.time()) + add_t
|
57
|
|
- next_rds = promotion_id + '@' + product_id + '@' + uid + '@' + room_id + '@' + str(news_time)
|
58
|
|
- rds_list.push_last_list(next_rds)
|
59
|
|
-
|
60
|
36
|
|
61
|
37
|
PrintLog.print(
|
62
|
38
|
time.strftime("%H:%M:%S", time.localtime()) + ' '
|
|
@@ -68,15 +44,49 @@ def scrape(request_data, heat):
|
68
|
44
|
|
69
|
45
|
commodity_detail = LiveCommodityDetailV1.get_data(product_id)
|
70
|
46
|
|
71
|
|
- if (commodity_detail is None) or (commodity_detail == ''):
|
|
47
|
+ if (commodity_detail is None) or (commodity_detail == '') or ('real_sell_num' in commodity_detail)==False :
|
72
|
48
|
rds_list.record_v1_score(0)
|
73
|
49
|
PrintLog.print(
|
74
|
50
|
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ' 数据为空 ' + promotion_id
|
75
|
51
|
)
|
76
|
|
- if random.randint(0, 9) > 0:
|
77
|
|
- rds_list.add_request_params(request_data, heat)
|
78
|
52
|
|
|
53
|
+ if heat==0:
|
|
54
|
+ rds_list.add_request_params(request_data, heat)
|
|
55
|
+ print('首次失败重新插入 ' + request_data)
|
|
56
|
+ sys.exit(0)
|
|
57
|
+
|
|
58
|
+ if heat>0:
|
|
59
|
+ if random.randint(0, 9) > 0:
|
|
60
|
+ rds_list.add_request_params(request_data, heat)
|
|
61
|
+ print(str(heat) + '非首次失败重新插入 ' + request_data)
|
|
62
|
+ sys.exit(0)
|
|
63
|
+
|
|
64
|
+ if heat < 2:
|
|
65
|
+ goodsDb = MysqlDyLiveCommodity()
|
|
66
|
+ pix = str(uid)[-1]
|
|
67
|
+ goodsInfo = goodsDb.get_goods_info(room_id, product_id, pix)
|
|
68
|
+
|
|
69
|
+ dataid,sold_out_at,revise_price,created_at = goodsInfo
|
|
70
|
+
|
|
71
|
+ if revise_price is not None:
|
|
72
|
+ sys.exit(0)
|
|
73
|
+
|
|
74
|
+ if sold_out_at == '0000-00-00 00:00:00' or sold_out_at == '1970-01-01 08:00:00':
|
|
75
|
+ add_t = 300
|
|
76
|
+ news_time = int(time.time()) + add_t
|
|
77
|
+ next_rds = promotion_id + '@' + product_id + '@' + uid + '@' + room_id + '@' + str(news_time)
|
|
78
|
+ rds_list.push_middle_list(next_rds)
|
|
79
|
+ print('中间插入 ' + next_rds)
|
|
80
|
+ else :
|
|
81
|
+ add_t = 1200
|
|
82
|
+ news_time = int(time.time()) + add_t
|
|
83
|
+ next_rds = promotion_id + '@' + product_id + '@' + uid + '@' + room_id + '@' + str(news_time)
|
|
84
|
+ rds_list.push_last_list(next_rds)
|
|
85
|
+ print('末次插入 ' + next_rds)
|
|
86
|
+
|
|
87
|
+ if (commodity_detail is None) or (commodity_detail == '') or ('real_sell_num' in commodity_detail)==False:
|
79
|
88
|
sys.exit(0)
|
|
89
|
+ print('失败----- ')
|
80
|
90
|
|
81
|
91
|
data = json.dumps({
|
82
|
92
|
"data": commodity_detail,
|
|
@@ -91,6 +101,7 @@ def scrape(request_data, heat):
|
91
|
101
|
|
92
|
102
|
rds_list.record_v1_score(1)
|
93
|
103
|
rds_list.push_v1_data_list(data)
|
|
104
|
+ print('成功+++++ ')
|
94
|
105
|
except Exception as e:
|
95
|
106
|
rds_list.record_v1_score(0)
|
96
|
107
|
rds_list.add_request_params(request_data, heat)
|