mdbq 2.3.3__py3-none-any.whl → 2.3.5__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/aggregation/aggregation.py +8 -8
- mdbq/aggregation/query_data.py +64 -0
- mdbq/clean/data_clean.py +14 -2
- mdbq/spider/aikucun.py +19 -17
- {mdbq-2.3.3.dist-info → mdbq-2.3.5.dist-info}/METADATA +1 -1
- {mdbq-2.3.3.dist-info → mdbq-2.3.5.dist-info}/RECORD +8 -8
- {mdbq-2.3.3.dist-info → mdbq-2.3.5.dist-info}/WHEEL +0 -0
- {mdbq-2.3.3.dist-info → mdbq-2.3.5.dist-info}/top_level.txt +0 -0
mdbq/aggregation/aggregation.py
CHANGED
@@ -526,7 +526,7 @@ class DatabaseUpdate:
|
|
526
526
|
elif name.endswith('.csv') and '竞店分析-来源分析-入店搜索词' in name:
|
527
527
|
df = pd.read_csv(os.path.join(root, name), encoding='utf-8_sig', header=0, na_filter=False)
|
528
528
|
check_remove_file = True
|
529
|
-
elif name.endswith('.csv') and '爱库存_商品榜单' in name:
|
529
|
+
elif name.endswith('.csv') and '爱库存_商品榜单_spu_' in name:
|
530
530
|
df = pd.read_csv(os.path.join(root, name), encoding='utf-8_sig', header=0, na_filter=False)
|
531
531
|
check_remove_file = True
|
532
532
|
# ----------------------- 京东数据处理分界线 -----------------------
|
@@ -1299,13 +1299,13 @@ if __name__ == '__main__':
|
|
1299
1299
|
username, password, host, port = get_myconf.select_config_values(target_service='nas', database='mysql')
|
1300
1300
|
print(username, password, host, port)
|
1301
1301
|
# file_dir(one_file=False, target_service='company')
|
1302
|
-
one_file_to_mysql(
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
)
|
1302
|
+
# one_file_to_mysql(
|
1303
|
+
# file='/Users/xigua/Downloads/爱库存_商品榜单_spu_2024-10-17_2024-10-17.csv',
|
1304
|
+
# db_name='爱库存2',
|
1305
|
+
# table_name='商品spu榜单',
|
1306
|
+
# target_service='company',
|
1307
|
+
# database='mysql'
|
1308
|
+
# )
|
1309
1309
|
|
1310
1310
|
# db_name = '推广数据2'
|
1311
1311
|
# table_name = '权益报表'
|
mdbq/aggregation/query_data.py
CHANGED
@@ -688,6 +688,53 @@ class MysqlDatasQuery:
|
|
688
688
|
df = pd.concat(_datas, axis=0, ignore_index=True)
|
689
689
|
return df
|
690
690
|
|
691
|
+
def aikucun_bd_spu(self):
|
692
|
+
start_date, end_date = self.months_data(num=self.months)
|
693
|
+
projection = {
|
694
|
+
'日期': 1,
|
695
|
+
'spi_id': 1,
|
696
|
+
'商品名称': 1,
|
697
|
+
'品牌名称': 1,
|
698
|
+
'商品款号': 1,
|
699
|
+
'一级类目名称': 1,
|
700
|
+
'二级类目名称': 1,
|
701
|
+
'三级类目名称': 1,
|
702
|
+
'转发次数': 1,
|
703
|
+
'转发爱豆人数': 1,
|
704
|
+
'访客量': 1,
|
705
|
+
'浏览量': 1,
|
706
|
+
'下单gmv': 1,
|
707
|
+
'成交gmv': 1,
|
708
|
+
'供货额': 1,
|
709
|
+
'供货价': 1,
|
710
|
+
'销售爱豆人数_成交': 1,
|
711
|
+
'支付人数_交易': 1,
|
712
|
+
'支付人数_成交': 1,
|
713
|
+
'销售量_成交': 1,
|
714
|
+
'销售量_交易': 1,
|
715
|
+
'订单数_成交': 1,
|
716
|
+
'订单数_交易': 1,
|
717
|
+
'成交率_交易': 1,
|
718
|
+
'成交率_成交': 1,
|
719
|
+
'可售库存数': 1,
|
720
|
+
'售罄率': 1,
|
721
|
+
'在架sku数': 1,
|
722
|
+
'可售sku数': 1,
|
723
|
+
'sku数_交易': 1,
|
724
|
+
'sku数_成交': 1,
|
725
|
+
'营销后供货额': 1,
|
726
|
+
'营销后供货价': 1,
|
727
|
+
}
|
728
|
+
projection = {}
|
729
|
+
df = self.download.data_to_df(
|
730
|
+
db_name='爱库存2',
|
731
|
+
table_name='商品spu榜单',
|
732
|
+
start_date=start_date,
|
733
|
+
end_date=end_date,
|
734
|
+
projection=projection,
|
735
|
+
)
|
736
|
+
return df
|
737
|
+
|
691
738
|
|
692
739
|
class GroupBy:
|
693
740
|
"""
|
@@ -822,6 +869,17 @@ class GroupBy:
|
|
822
869
|
return df
|
823
870
|
elif '商品索引表' in table_name:
|
824
871
|
return df
|
872
|
+
elif '爱库存_商品spu榜单' in table_name:
|
873
|
+
df.drop_duplicates(
|
874
|
+
subset=[
|
875
|
+
'日期',
|
876
|
+
'spu_id',
|
877
|
+
'访客量',
|
878
|
+
'浏览量',
|
879
|
+
'下单gmv',
|
880
|
+
'成交gmv',
|
881
|
+
], keep='last', inplace=True, ignore_index=True)
|
882
|
+
return df
|
825
883
|
elif '人群报表' in table_name:
|
826
884
|
df.rename(columns={
|
827
885
|
'场景名字': '营销场景',
|
@@ -1713,6 +1771,12 @@ def data_aggregation(service_databases=[{}], months=1):
|
|
1713
1771
|
'唯一主键': [],
|
1714
1772
|
'数据主体': sdq.tg_by_day(),
|
1715
1773
|
},
|
1774
|
+
{
|
1775
|
+
'数据库名': '聚合数据',
|
1776
|
+
'集合名': '爱库存_商品spu榜单',
|
1777
|
+
'唯一主键': [],
|
1778
|
+
'数据主体': sdq.aikucun_bd_spu(),
|
1779
|
+
},
|
1716
1780
|
]
|
1717
1781
|
for items in data_dict: # 遍历返回结果
|
1718
1782
|
db_name, table_name, unique_key_list, df = items['数据库名'], items['集合名'], items['唯一主键'], items['数据主体']
|
mdbq/clean/data_clean.py
CHANGED
@@ -1142,11 +1142,23 @@ class DataClean:
|
|
1142
1142
|
shutil.move(os.path.join(path, _name), t2) # 将文件从下载文件夹移到目标位置
|
1143
1143
|
|
1144
1144
|
# @try_except
|
1145
|
-
def move_all(self, path=None):
|
1145
|
+
def move_all(self, path=None, is_except=[]):
|
1146
1146
|
if not path:
|
1147
1147
|
path = self.path
|
1148
1148
|
for root, dirs, files in os.walk(path, topdown=False):
|
1149
1149
|
for name in files:
|
1150
|
+
# print(name)
|
1151
|
+
is_continue = False
|
1152
|
+
if is_except:
|
1153
|
+
for item in is_except:
|
1154
|
+
print(item, f'-----', os.path.join(root, name))
|
1155
|
+
if item in os.path.join(root, name):
|
1156
|
+
# print(name)
|
1157
|
+
is_continue = True
|
1158
|
+
break
|
1159
|
+
if is_continue: # 需要排除不做处理的文件或文件夹
|
1160
|
+
continue
|
1161
|
+
# print(is_except, is_continue)
|
1150
1162
|
def bib(paths, _as_month=None):
|
1151
1163
|
"""闭包函数"""
|
1152
1164
|
self.move_files(path=path, _name=name, target_path=paths, _as_month=_as_month)
|
@@ -1336,7 +1348,7 @@ class DataClean:
|
|
1336
1348
|
elif name.endswith('.csv') and '京东推广关键词点击成交报表' in name:
|
1337
1349
|
t_path = str(pathlib.Path(self.source_path, '京东报表/JD推广_关键词报表'))
|
1338
1350
|
bib(t_path, _as_month=True)
|
1339
|
-
elif name.endswith('.csv') and '爱库存
|
1351
|
+
elif name.endswith('.csv') and '爱库存_商品榜单_spu_' in name:
|
1340
1352
|
t_path = str(pathlib.Path(self.source_path, '爱库存/商品榜单'))
|
1341
1353
|
bib(t_path, _as_month=True)
|
1342
1354
|
# 京东分界线 ------- 结束标记
|
mdbq/spider/aikucun.py
CHANGED
@@ -43,11 +43,12 @@ else:
|
|
43
43
|
Source_Path = str(pathlib.Path(Data_Path, '原始文件2'))
|
44
44
|
|
45
45
|
|
46
|
-
def
|
46
|
+
def get_cookie_aikucun():
|
47
47
|
"""
|
48
48
|
"""
|
49
49
|
_url = 'https://gray-merc.aikucun.com/index.html'
|
50
|
-
cookie_path = '
|
50
|
+
cookie_path = os.path.join(set_support.SetSupport(dirname='support').dirname, 'cookies')
|
51
|
+
filename_aikucun = 'cookie_aikucun.txt'
|
51
52
|
print(_url)
|
52
53
|
|
53
54
|
option = webdriver.ChromeOptions() # 浏览器启动选项
|
@@ -79,7 +80,6 @@ def test():
|
|
79
80
|
service = Service(chromedriver_path)
|
80
81
|
_driver = webdriver.Chrome(service=service, options=option) # 创建Chrome驱动程序实例
|
81
82
|
|
82
|
-
print('yes')
|
83
83
|
# 登录
|
84
84
|
_driver.get(_url)
|
85
85
|
time.sleep(0.1)
|
@@ -91,16 +91,16 @@ def test():
|
|
91
91
|
time.sleep(0.1)
|
92
92
|
|
93
93
|
|
94
|
-
_file = os.path.join(cookie_path,
|
94
|
+
_file = os.path.join(cookie_path, filename_aikucun)
|
95
95
|
with open(_file, 'w') as f:
|
96
96
|
# 将cookies保存为json格式
|
97
97
|
cookies_list = _driver.get_cookies()
|
98
|
-
for cookie in cookies_list:
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
# for cookie in cookies_list:
|
99
|
+
# # 该字段有问题所以删除就可以
|
100
|
+
# if 'expiry' in cookie:
|
101
|
+
# del cookie['expiry']
|
102
|
+
# # if 'domain' in cookie:
|
103
|
+
# # cookie['domain'] = '.taobao.com'
|
104
104
|
cookies_list = json.dumps(cookies_list)
|
105
105
|
f.write(cookies_list)
|
106
106
|
print(f'cookie已保存: {_file}')
|
@@ -109,7 +109,8 @@ def test():
|
|
109
109
|
|
110
110
|
class AikuCun:
|
111
111
|
def __init__(self):
|
112
|
-
self.url = 'https://gray-merc.aikucun.com/index.html'
|
112
|
+
# self.url = 'https://gray-merc.aikucun.com/index.html'
|
113
|
+
self.sp_url = 'https://treasurebox.aikucun.com/dashboard/commodity/ranking/merchant?LS=true&shopId=1814114991487782914&from=menu&v=0.1936043279838604'
|
113
114
|
self.cookie_path = os.path.join(set_support.SetSupport(dirname='support').dirname, 'cookies')
|
114
115
|
|
115
116
|
def login(self, shop_name='aikucun'):
|
@@ -173,7 +174,7 @@ class AikuCun:
|
|
173
174
|
_driver.maximize_window() # 窗口最大化 方便后续加载数据
|
174
175
|
|
175
176
|
# 登录
|
176
|
-
_driver.get(self.
|
177
|
+
_driver.get(self.sp_url)
|
177
178
|
_driver.delete_all_cookies() # 首先清除浏览器打开已有的cookies
|
178
179
|
name_lists = os.listdir(self.cookie_path) # cookie 放在主目录下的 cookies 文件夹
|
179
180
|
for name in name_lists:
|
@@ -193,9 +194,10 @@ class AikuCun:
|
|
193
194
|
"""
|
194
195
|
|
195
196
|
_driver = self.login(shop_name=shop_name)
|
196
|
-
|
197
|
-
_driver.get(
|
197
|
+
|
198
|
+
_driver.get(self.sp_url)
|
198
199
|
time.sleep(3)
|
200
|
+
# breakpoint()
|
199
201
|
|
200
202
|
today = datetime.date.today()
|
201
203
|
for date_s in range(date_num):
|
@@ -271,7 +273,7 @@ class AikuCun:
|
|
271
273
|
|
272
274
|
def akucun():
|
273
275
|
akc = AikuCun()
|
274
|
-
akc.get_data(shop_name='aikucun', date_num=
|
276
|
+
akc.get_data(shop_name='aikucun', date_num=2)
|
275
277
|
# akc.clean_data()
|
276
278
|
|
277
279
|
# 新版 数据分类
|
@@ -291,10 +293,10 @@ def akucun():
|
|
291
293
|
c.set_up_to_mysql = False # 不再使用 data_clean 更新数据库,改为 aggregation.py
|
292
294
|
c.new_unzip(is_move=True, ) # 解压文件
|
293
295
|
c.change_and_sort(is_except=['临时文件'])
|
294
|
-
c.move_all() # 移到文件到原始文件夹
|
296
|
+
c.move_all(is_except=['临时文件']) # 移到文件到原始文件夹
|
295
297
|
|
296
298
|
|
297
299
|
if __name__ == '__main__':
|
298
300
|
pass
|
299
|
-
#
|
301
|
+
# get_cookie_aikucun()
|
300
302
|
akucun()
|
@@ -1,15 +1,15 @@
|
|
1
1
|
mdbq/__init__.py,sha256=Il5Q9ATdX8yXqVxtP_nYqUhExzxPC_qk_WXQ_4h0exg,16
|
2
2
|
mdbq/__version__.py,sha256=y9Mp_8x0BCZSHsdLT_q5tX9wZwd5QgqrSIENLrb6vXA,62
|
3
3
|
mdbq/aggregation/__init__.py,sha256=EeDqX2Aml6SPx8363J-v1lz0EcZtgwIBYyCJV6CcEDU,40
|
4
|
-
mdbq/aggregation/aggregation.py,sha256=
|
4
|
+
mdbq/aggregation/aggregation.py,sha256=CS_gMBwPKQo7uId8BrsYNTjtCZKzRVV7gT4PfE2Q46k,76014
|
5
5
|
mdbq/aggregation/df_types.py,sha256=U9i3q2eRPTDY8qAPTw7irzu-Tlg4CIySW9uYro81wdk,8125
|
6
6
|
mdbq/aggregation/mysql_types.py,sha256=DQYROALDiwjJzjhaJfIIdnsrNs11i5BORlj_v6bp67Y,11062
|
7
7
|
mdbq/aggregation/optimize_data.py,sha256=Wis40oL04M7E1pkvgNPjyVFAUe-zgjimjIVAikxYY8Y,4418
|
8
|
-
mdbq/aggregation/query_data.py,sha256
|
8
|
+
mdbq/aggregation/query_data.py,sha256=-iXeXTTdAEmFLvoOGIKB-6-moszxRCATtNe2QBzucZo,87524
|
9
9
|
mdbq/bdup/__init__.py,sha256=AkhsGk81SkG1c8FqDH5tRq-8MZmFobVbN60DTyukYTY,28
|
10
10
|
mdbq/bdup/bdup.py,sha256=LAV0TgnQpc-LB-YuJthxb0U42_VkPidzQzAagan46lU,4234
|
11
11
|
mdbq/clean/__init__.py,sha256=A1d6x3L27j4NtLgiFV5TANwEkLuaDfPHDQNrPBbNWtU,41
|
12
|
-
mdbq/clean/data_clean.py,sha256=
|
12
|
+
mdbq/clean/data_clean.py,sha256=QvbM_mRHvUbwvJu0UpJu4SUQNxLWsFl7QApoq6cPiVU,104788
|
13
13
|
mdbq/company/__init__.py,sha256=qz8F_GsP_pMB5PblgJAUAMjasuZbOEp3qQOCB39E8f0,21
|
14
14
|
mdbq/company/copysh.py,sha256=xjlfb-RwW0oLyyHQZFUtmXvCpWI7Y_nhwa0tqW14wZk,19345
|
15
15
|
mdbq/company/home_sh.py,sha256=42CZ2tZIXHLl2mOl2gk2fZnjH2IHh1VJ1s3qHABjonY,18021
|
@@ -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=P5RiXEgwQR44KhBcrgolFPipqILQ4eieDC7MpSWDlkE,18346
|
42
42
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
43
|
-
mdbq/spider/aikucun.py,sha256=
|
44
|
-
mdbq-2.3.
|
45
|
-
mdbq-2.3.
|
46
|
-
mdbq-2.3.
|
47
|
-
mdbq-2.3.
|
43
|
+
mdbq/spider/aikucun.py,sha256=fszwS5jml5-S98u5FurBKVS2L4O-0wXFdU6CsGqbWrE,14104
|
44
|
+
mdbq-2.3.5.dist-info/METADATA,sha256=p6gnM-ZXnkZm1VLCgsF3NiAPaV0zsiwF1nGyHJ-qOPY,245
|
45
|
+
mdbq-2.3.5.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
46
|
+
mdbq-2.3.5.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
47
|
+
mdbq-2.3.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|