mns-common 1.3.6.2__py3-none-any.whl → 1.3.6.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mns-common might be problematic. Click here for more details.
- mns_common/component/proxies/__init__.py +7 -0
- mns_common/component/proxies/proxy_common_api.py +80 -0
- mns_common/constant/db_name_constant.py +4 -0
- {mns_common-1.3.6.2.dist-info → mns_common-1.3.6.4.dist-info}/METADATA +1 -1
- {mns_common-1.3.6.2.dist-info → mns_common-1.3.6.4.dist-info}/RECORD +7 -5
- {mns_common-1.3.6.2.dist-info → mns_common-1.3.6.4.dist-info}/WHEEL +0 -0
- {mns_common-1.3.6.2.dist-info → mns_common-1.3.6.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
file_path = os.path.abspath(__file__)
|
|
5
|
+
end = file_path.index('mns') + 16
|
|
6
|
+
project_path = file_path[0:end]
|
|
7
|
+
sys.path.append(project_path)
|
|
8
|
+
|
|
9
|
+
import mns_common.api.proxies.liu_guan_proxy_api as liu_guan_proxy_api
|
|
10
|
+
from functools import lru_cache
|
|
11
|
+
import pandas as pd
|
|
12
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
13
|
+
from mns_common.db.MongodbUtil import MongodbUtil
|
|
14
|
+
import mns_common.constant.db_name_constant as db_name_constant
|
|
15
|
+
import datetime
|
|
16
|
+
|
|
17
|
+
mongodb_util = MongodbUtil('27017')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@lru_cache(maxsize=None)
|
|
21
|
+
def query_liu_guan_proxy_ip():
|
|
22
|
+
ip_proxy_pool = mongodb_util.find_all_data(db_name_constant.IP_PROXY_POOL)
|
|
23
|
+
return ip_proxy_pool
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def clear_proxy_ip_cache():
|
|
27
|
+
query_liu_guan_proxy_ip.cache_clear()
|
|
28
|
+
mongodb_util.remove_data({}, db_name_constant.IP_PROXY_POOL)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def check_valid(str_now_date, ip_proxy_pool):
|
|
32
|
+
effect_time = list(ip_proxy_pool['effect_time'])[0]
|
|
33
|
+
if effect_time > str_now_date:
|
|
34
|
+
return True
|
|
35
|
+
else:
|
|
36
|
+
clear_proxy_ip_cache()
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def generate_proxy_ip():
|
|
41
|
+
query = {"type": "liu_guan_proxy", }
|
|
42
|
+
stock_account_info = mongodb_util.find_query_data(db_name_constant.STOCK_ACCOUNT_INFO, query)
|
|
43
|
+
order_id = list(stock_account_info['password'])[0]
|
|
44
|
+
secret = list(stock_account_info['account'])[0]
|
|
45
|
+
|
|
46
|
+
now_date = datetime.datetime.now()
|
|
47
|
+
time_to_add = datetime.timedelta(minutes=9, seconds=40)
|
|
48
|
+
new_date = now_date + time_to_add
|
|
49
|
+
str_now_date = new_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
50
|
+
|
|
51
|
+
# 获取10分钟动态ip
|
|
52
|
+
ip = liu_guan_proxy_api.get_proxy_api(order_id, secret, '600')
|
|
53
|
+
|
|
54
|
+
result_dict = {"_id": ip,
|
|
55
|
+
'effect_time': str_now_date,
|
|
56
|
+
'ip': ip}
|
|
57
|
+
result_df = pd.DataFrame(result_dict, index=[1])
|
|
58
|
+
|
|
59
|
+
mongodb_util.insert_mongo(result_df, db_name_constant.IP_PROXY_POOL)
|
|
60
|
+
|
|
61
|
+
return ip
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def get_proxy_ip(str_now_date):
|
|
65
|
+
ip_proxy_pool = query_liu_guan_proxy_ip()
|
|
66
|
+
if data_frame_util.is_empty(ip_proxy_pool):
|
|
67
|
+
return generate_proxy_ip()
|
|
68
|
+
else:
|
|
69
|
+
if check_valid(str_now_date, ip_proxy_pool):
|
|
70
|
+
return list(ip_proxy_pool['ip'])[0]
|
|
71
|
+
else:
|
|
72
|
+
return generate_proxy_ip()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == '__main__':
|
|
76
|
+
while True:
|
|
77
|
+
now_date = datetime.datetime.now()
|
|
78
|
+
str_now_date_test = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
79
|
+
ip_test = get_proxy_ip(str_now_date_test)
|
|
80
|
+
print(ip_test)
|
|
@@ -106,6 +106,8 @@ mns_common/component/k_line/patterns/k_line_patterns_service_api.py,sha256=C5mg4
|
|
|
106
106
|
mns_common/component/k_line/patterns/pattern_Enum.py,sha256=bl8cH1H3BWdj_deVO124oSGYMPUtDQWvqqWk_5rf5rQ,509
|
|
107
107
|
mns_common/component/price/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
108
108
|
mns_common/component/price/trade_price_service_api.py,sha256=0loBjbOt__o-ngc2Q4n5lF8_0x2WINRpL-cH1341Uaw,4396
|
|
109
|
+
mns_common/component/proxies/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
110
|
+
mns_common/component/proxies/proxy_common_api.py,sha256=OlTpafPX6xg-yIumUQlQE9KhhoCUd4FsFcDOknD5MX8,2477
|
|
109
111
|
mns_common/component/qmt/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
110
112
|
mns_common/component/qmt/qmt_buy_service.py,sha256=tLTgrSxCcxuMhADRBBrW4ZWR_3MdbMZvvMdH5hbwyJU,7190
|
|
111
113
|
mns_common/component/real_time/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
@@ -125,7 +127,7 @@ mns_common/component/zt/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3Hi
|
|
|
125
127
|
mns_common/component/zt/zt_common_service_api.py,sha256=6pHRLLJjKcLLBA-xXkAU8SE6DZ5dgVFBRVjJmhkL0II,11945
|
|
126
128
|
mns_common/constant/__init__.py,sha256=xu36nA6MJTauswUWPfKIKH0E-lpOAHTw2TL5QI_6TeY,165
|
|
127
129
|
mns_common/constant/black_list_classify_enum.py,sha256=I8U_DcltzYvlWjgn-TFLImgVgPuO0lxMnEJAQJBljdo,3995
|
|
128
|
-
mns_common/constant/db_name_constant.py,sha256=
|
|
130
|
+
mns_common/constant/db_name_constant.py,sha256=Mdgik6YRQC9xZ23hDzfOy0twFEyrqM6X627N2wnLe_k,4249
|
|
129
131
|
mns_common/constant/east_money_stock_api.py,sha256=mW0b8sEgkf8WJtars2frOQYzsWgjIl4FDYEwcCcCSZY,7557
|
|
130
132
|
mns_common/constant/extra_income_db_name.py,sha256=AsIO1CtcVRq9k7TKtjFA1KzuL_jvAw2hA_Uq44wQL7o,1198
|
|
131
133
|
mns_common/constant/price_enum.py,sha256=nhcPxk0AFdQAp8IsNr5EP9xURLqqJuSl6ljIzTp7Wyo,1093
|
|
@@ -144,7 +146,7 @@ mns_common/utils/date_handle_util.py,sha256=XS-MyA8_7k35LOCFAYOHgVcVkMft_Kc4Wa9U
|
|
|
144
146
|
mns_common/utils/db_util.py,sha256=hSmfNAN4vEeEaUva6_cicZEhb2jSnib-Gvk2reke1vc,2590
|
|
145
147
|
mns_common/utils/file_util.py,sha256=egWu6PenGPRp_ixrNTHKarT4dAnOT6FETR82EHUZJnQ,1042
|
|
146
148
|
mns_common/utils/ip_util.py,sha256=UTcYfz_uytB__6nlBf7T-izuI7hi4XdB6ET0sJgEel4,969
|
|
147
|
-
mns_common-1.3.6.
|
|
148
|
-
mns_common-1.3.6.
|
|
149
|
-
mns_common-1.3.6.
|
|
150
|
-
mns_common-1.3.6.
|
|
149
|
+
mns_common-1.3.6.4.dist-info/METADATA,sha256=GsYgCbbdHocFF4mV9ob3gK6DkdOhwhmK_kvlrrigCzA,61
|
|
150
|
+
mns_common-1.3.6.4.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
151
|
+
mns_common-1.3.6.4.dist-info/top_level.txt,sha256=ZC58kAR-8Hvc6U2xhYNBNLAh3mb6sZazbdj5nZpvEkQ,11
|
|
152
|
+
mns_common-1.3.6.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|