mdbq 2.4.9__py3-none-any.whl → 2.5.1__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.
- mdbq/mysql/mysql.py +10 -7
- mdbq/spider/aikucun.py +23 -16
- {mdbq-2.4.9.dist-info → mdbq-2.5.1.dist-info}/METADATA +1 -1
- {mdbq-2.4.9.dist-info → mdbq-2.5.1.dist-info}/RECORD +6 -6
- {mdbq-2.4.9.dist-info → mdbq-2.5.1.dist-info}/WHEEL +0 -0
- {mdbq-2.4.9.dist-info → mdbq-2.5.1.dist-info}/top_level.txt +0 -0
mdbq/mysql/mysql.py
CHANGED
@@ -684,13 +684,16 @@ class OptimizeDatas:
|
|
684
684
|
duplicate_id = [] # 出现重复的 id
|
685
685
|
all_datas = [] # 迭代器
|
686
686
|
for data in datas:
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
687
|
+
try:
|
688
|
+
delete_id = data['id']
|
689
|
+
del data['id']
|
690
|
+
data = re.sub(r'\.0+\', ', '\', ', str(data)) # 统一移除小数点后面的 0
|
691
|
+
if data in all_datas: # 数据出现重复时
|
692
|
+
duplicate_id.append(delete_id) # 添加 id 到 duplicate_id
|
693
|
+
continue
|
694
|
+
all_datas.append(data) # 数据没有重复
|
695
|
+
except Exception as e:
|
696
|
+
print(f'{table_name} 函数: mysql - > OptimizeDatas -> delete_duplicate -> {e}')
|
694
697
|
del all_datas
|
695
698
|
|
696
699
|
if not duplicate_id: # 如果没有重复数据,则跳过该数据表
|
mdbq/spider/aikucun.py
CHANGED
@@ -48,7 +48,7 @@ def get_cookie_aikucun():
|
|
48
48
|
"""
|
49
49
|
_url = 'https://gray-merc.aikucun.com/index.html'
|
50
50
|
cookie_path = os.path.join(set_support.SetSupport(dirname='support').dirname, 'cookies')
|
51
|
-
filename_aikucun = 'cookie_aikucun.
|
51
|
+
filename_aikucun = 'cookie_aikucun.json'
|
52
52
|
print(_url)
|
53
53
|
|
54
54
|
option = webdriver.ChromeOptions() # 浏览器启动选项
|
@@ -90,20 +90,27 @@ def get_cookie_aikucun():
|
|
90
90
|
print(f'{d_time} 登录成功,正在获取cookie...')
|
91
91
|
time.sleep(0.1)
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
93
|
+
# 将cookies保存为json格式
|
94
|
+
cookies_list = _driver.get_cookies()
|
95
|
+
|
96
|
+
json_file = os.path.join(cookie_path, filename_aikucun)
|
97
|
+
with open(json_file, 'w', encoding='utf-8') as f:
|
98
|
+
json.dump(cookies_list, f, ensure_ascii=False, sort_keys=True, indent=4)
|
99
|
+
print(f'cookie已保存: {json_file}')
|
100
|
+
|
101
|
+
# _file = os.path.join(cookie_path, filename_aikucun)
|
102
|
+
# with open(_file, 'w') as f:
|
103
|
+
# # 将cookies保存为json格式
|
104
|
+
# cookies_list = _driver.get_cookies()
|
105
|
+
# # for cookie in cookies_list:
|
106
|
+
# # # 该字段有问题所以删除就可以
|
107
|
+
# # if 'expiry' in cookie:
|
108
|
+
# # del cookie['expiry']
|
109
|
+
# # # if 'domain' in cookie:
|
110
|
+
# # # cookie['domain'] = '.taobao.com'
|
111
|
+
# cookies_list = json.dumps(cookies_list)
|
112
|
+
# f.write(cookies_list)
|
113
|
+
# print(f'cookie已保存: {_file}')
|
107
114
|
_driver.quit()
|
108
115
|
|
109
116
|
|
@@ -178,7 +185,7 @@ class AikuCun:
|
|
178
185
|
_driver.delete_all_cookies() # 首先清除浏览器打开已有的cookies
|
179
186
|
name_lists = os.listdir(self.cookie_path) # cookie 放在主目录下的 cookies 文件夹
|
180
187
|
for name in name_lists:
|
181
|
-
if shop_name in name and name.endswith('.
|
188
|
+
if shop_name in name and name.endswith('.json') and '~' not in name and '.DS' not in name:
|
182
189
|
with open(os.path.join(self.cookie_path, name), 'r') as f:
|
183
190
|
cookies_list = json.load(f) # 使用json读取cookies 注意读取的是文件 所以用load而不是loads
|
184
191
|
for cookie in cookies_list:
|
@@ -25,7 +25,7 @@ mdbq/log/mylogger.py,sha256=oaT7Bp-Hb9jZt52seP3ISUuxVcI19s4UiqTeouScBO0,3258
|
|
25
25
|
mdbq/mongo/__init__.py,sha256=SILt7xMtQIQl_m-ik9WLtJSXIVf424iYgCfE_tnQFbw,13
|
26
26
|
mdbq/mongo/mongo.py,sha256=v9qvrp6p1ZRWuPpbSilqveiE0FEcZF7U5xUPI0RN4xs,31880
|
27
27
|
mdbq/mysql/__init__.py,sha256=A_DPJyAoEvTSFojiI2e94zP0FKtCkkwKP1kYUCSyQzo,11
|
28
|
-
mdbq/mysql/mysql.py,sha256=
|
28
|
+
mdbq/mysql/mysql.py,sha256=39323KfZxN5DRyXhBEv5Hgw4TkzBs0wm0lMN1uYsE9A,47028
|
29
29
|
mdbq/mysql/s_query.py,sha256=37GGHzRpycfUjsYEoQgDpdEs9JwjW-LxFXnGwwP2b2Q,8403
|
30
30
|
mdbq/mysql/year_month_day.py,sha256=VgewoE2pJxK7ErjfviL_SMTN77ki8GVbTUcao3vFUCE,1523
|
31
31
|
mdbq/other/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
@@ -40,8 +40,8 @@ mdbq/pbix/refresh_all_old.py,sha256=_pq3WSQ728GPtEG5pfsZI2uTJhU8D6ra-htIk1JXYzw,
|
|
40
40
|
mdbq/req_post/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
41
41
|
mdbq/req_post/req_tb.py,sha256=PexWSCPJNM6Tv0ol4lAWIhlOwsAr_frnjtcdSHCFiek,36179
|
42
42
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
43
|
-
mdbq/spider/aikucun.py,sha256=
|
44
|
-
mdbq-2.
|
45
|
-
mdbq-2.
|
46
|
-
mdbq-2.
|
47
|
-
mdbq-2.
|
43
|
+
mdbq/spider/aikucun.py,sha256=KdihSB3q44jsXUQAldfWRVfCSrEw2MNbM-_BhP_29g4,14448
|
44
|
+
mdbq-2.5.1.dist-info/METADATA,sha256=jazgEXlxIaY4qkOGCU1Gj_wRumfQQx9oQ9qnFzHr28g,245
|
45
|
+
mdbq-2.5.1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
46
|
+
mdbq-2.5.1.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
47
|
+
mdbq-2.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|