mdbq 2.1.2__py3-none-any.whl → 2.1.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.
- mdbq/aggregation/aggregation.py +1 -0
- mdbq/company/copysh.py +10 -0
- mdbq/other/sku_picture.py +25 -12
- {mdbq-2.1.2.dist-info → mdbq-2.1.4.dist-info}/METADATA +1 -1
- {mdbq-2.1.2.dist-info → mdbq-2.1.4.dist-info}/RECORD +7 -7
- {mdbq-2.1.2.dist-info → mdbq-2.1.4.dist-info}/WHEEL +0 -0
- {mdbq-2.1.2.dist-info → mdbq-2.1.4.dist-info}/top_level.txt +0 -0
mdbq/aggregation/aggregation.py
CHANGED
mdbq/company/copysh.py
CHANGED
@@ -21,6 +21,7 @@ from mdbq.config import set_support
|
|
21
21
|
from mdbq.config import products
|
22
22
|
from mdbq.mysql import mysql
|
23
23
|
from mdbq.pbix import refresh_all
|
24
|
+
from mdbq.other import sku_picture
|
24
25
|
warnings.filterwarnings('ignore')
|
25
26
|
|
26
27
|
|
@@ -361,6 +362,15 @@ def main():
|
|
361
362
|
dp.upload_df(service_databases=[{'company': 'mysql'}])
|
362
363
|
dp.date_table(service_databases=[{'company': 'mysql'}]) # 因为日期表不受 days 参数控制,因此单独更新日期表
|
363
364
|
dp.other_table(service_databases=[{'company': 'mysql'}]) # 上传 support 文件夹下的 主推商品.csv
|
365
|
+
if datetime.datetime.now().day in [1, 3, 7, 9, 12, 16, 19, 22, 25, 27]:
|
366
|
+
sku_picture.download_spu(
|
367
|
+
service_name='company',
|
368
|
+
database='mysql',
|
369
|
+
db_name='属性设置2',
|
370
|
+
table_name='商品spu素材下载记录',
|
371
|
+
col_name='商品图片',
|
372
|
+
save_path=os.path.join(f'\\\\192.168.1.198\\时尚事业部\\01.运营部\\天猫报表\\其他文件', '商品id_商家编码_图片'),
|
373
|
+
)
|
364
374
|
|
365
375
|
# 此操作用于修改 .copysh_conf 文件,将 ch_record 改为 false (更新完成)
|
366
376
|
w = update_conf.UpdateConf()
|
mdbq/other/sku_picture.py
CHANGED
@@ -28,8 +28,13 @@ import io
|
|
28
28
|
from openpyxl import load_workbook
|
29
29
|
from openpyxl.drawing.image import Image
|
30
30
|
from openpyxl.utils import get_column_letter
|
31
|
+
from setuptools.sandbox import save_path
|
31
32
|
|
32
33
|
warnings.filterwarnings('ignore')
|
34
|
+
"""
|
35
|
+
用来下载商品spu/sku图片素材
|
36
|
+
"""
|
37
|
+
|
33
38
|
|
34
39
|
if platform.system() == 'Windows':
|
35
40
|
D_PATH = os.path.normpath(f'C:\\Users\\{getpass.getuser()}\\Downloads')
|
@@ -502,10 +507,8 @@ class DownloadPicture():
|
|
502
507
|
self.download = s_query.QueryDatas(username=username, password=password, host=host, port=port)
|
503
508
|
self.df = pd.DataFrame()
|
504
509
|
self.headers = {'User-Agent': ua_sj.get_ua()}
|
505
|
-
self.save_path =
|
510
|
+
self.save_path = None
|
506
511
|
self.filename = ''
|
507
|
-
if not os.path.exists(self.save_path):
|
508
|
-
os.mkdir(self.save_path)
|
509
512
|
self.local_file = ''
|
510
513
|
self.finish_download = []
|
511
514
|
|
@@ -532,8 +535,8 @@ class DownloadPicture():
|
|
532
535
|
self.df = pd.read_excel(self.local_file, header=0, engine='openpyxl')
|
533
536
|
|
534
537
|
def download_data(self):
|
535
|
-
if not os.path.exists(self.save_path):
|
536
|
-
|
538
|
+
# if not os.path.exists(self.save_path):
|
539
|
+
# os.mkdir(self.save_path)
|
537
540
|
dict_data = self.df.to_dict('records')
|
538
541
|
num = len(dict_data)
|
539
542
|
i = 0
|
@@ -557,7 +560,8 @@ class DownloadPicture():
|
|
557
560
|
i += 1
|
558
561
|
time.sleep(0.5)
|
559
562
|
|
560
|
-
def download_data_from_local(self, col_name='sku图片链接'):
|
563
|
+
def download_data_from_local(self, col_name='sku图片链接', save_path=os.path.join(D_PATH, 'sku图片链接')):
|
564
|
+
self.save_path = save_path
|
561
565
|
if not os.path.exists(self.save_path):
|
562
566
|
os.mkdir(self.save_path)
|
563
567
|
dict_data = self.df.to_dict('records')
|
@@ -583,7 +587,8 @@ class DownloadPicture():
|
|
583
587
|
i += 1
|
584
588
|
time.sleep(0.5)
|
585
589
|
|
586
|
-
def download_from_df(self, col_name='商品图片'):
|
590
|
+
def download_from_df(self, col_name='商品图片', save_path=os.path.join(D_PATH, '商品id_商家编码_图片')):
|
591
|
+
self.save_path = save_path
|
587
592
|
if not os.path.exists(self.save_path):
|
588
593
|
os.mkdir(self.save_path)
|
589
594
|
dict_data = self.df.to_dict('records')
|
@@ -591,7 +596,8 @@ class DownloadPicture():
|
|
591
596
|
i = 1
|
592
597
|
for data in dict_data:
|
593
598
|
url = data[col_name]
|
594
|
-
self.filename = f'{data['店铺名称']}_{data['商品id']}_{data['商家编码']}.jpg'
|
599
|
+
# self.filename = f'{data['店铺名称']}_{data['商品id']}_{data['商家编码']}.jpg'
|
600
|
+
self.filename = f'{data['商品id']}_{data['商家编码']}.jpg'
|
595
601
|
if os.path.isfile(os.path.join(self.save_path, self.filename)):
|
596
602
|
self.finish_download.append(data['商品id'])
|
597
603
|
i += 1
|
@@ -913,7 +919,7 @@ def download_sku(service_name='company', database='mysql', db_name='属性设置
|
|
913
919
|
) # 3. 回传数据库
|
914
920
|
|
915
921
|
|
916
|
-
def download_spu(service_name='company', database='mysql', db_name='属性设置2', table_name='商品spu素材下载记录', col_name='商品图片'):
|
922
|
+
def download_spu(service_name='company', database='mysql', db_name='属性设置2', table_name='商品spu素材下载记录', col_name='商品图片', save_path=os.path.join(D_PATH, '商品id_商家编码_图片')):
|
917
923
|
"""
|
918
924
|
|
919
925
|
"""
|
@@ -1007,10 +1013,10 @@ def download_spu(service_name='company', database='mysql', db_name='属性设置
|
|
1007
1013
|
if len(df) > 0:
|
1008
1014
|
# 5. 实例化一个下载器类,并下载数据
|
1009
1015
|
d = DownloadPicture(service_name=service_name)
|
1010
|
-
d.save_path =
|
1016
|
+
d.save_path = save_path # 下载图片到本地时的存储位置
|
1011
1017
|
d.filename = f'{db_name}_{table_name}.xlsx'
|
1012
1018
|
d.df = df
|
1013
|
-
d.download_from_df(col_name=col_name)
|
1019
|
+
d.download_from_df(col_name=col_name, save_path=save_path)
|
1014
1020
|
df['获取与下载'] = df.apply(lambda x: '已下载' if x['商品id'] in d.finish_download else x['获取与下载'], axis=1)
|
1015
1021
|
|
1016
1022
|
# 6. 回传数据库
|
@@ -1034,4 +1040,11 @@ if __name__ == '__main__':
|
|
1034
1040
|
# main2(service_name='home_lx', database='mysql')
|
1035
1041
|
# main3()
|
1036
1042
|
# download_sku(service_name='company', database='mysql', db_name='属性设置2', table_name='商品素材下载记录')
|
1037
|
-
download_spu(
|
1043
|
+
download_spu(
|
1044
|
+
service_name='company',
|
1045
|
+
database='mysql',
|
1046
|
+
db_name='属性设置2',
|
1047
|
+
table_name='商品spu素材下载记录',
|
1048
|
+
col_name='商品图片',
|
1049
|
+
save_path=os.path.join(D_PATH, '1商品id_商家编码_图片'),
|
1050
|
+
)
|
@@ -1,7 +1,7 @@
|
|
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=kJW1RhdIc0b91Ywmx0N3khHHg7ivVEK0RsmuWdWp6zU,75870
|
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
|
@@ -11,7 +11,7 @@ mdbq/bdup/bdup.py,sha256=LAV0TgnQpc-LB-YuJthxb0U42_VkPidzQzAagan46lU,4234
|
|
11
11
|
mdbq/clean/__init__.py,sha256=A1d6x3L27j4NtLgiFV5TANwEkLuaDfPHDQNrPBbNWtU,41
|
12
12
|
mdbq/clean/data_clean.py,sha256=ZJOTT0sNWP85x4pJl39UZBwN4Bnf8Ao-iVOJNiiRPEE,103996
|
13
13
|
mdbq/company/__init__.py,sha256=qz8F_GsP_pMB5PblgJAUAMjasuZbOEp3qQOCB39E8f0,21
|
14
|
-
mdbq/company/copysh.py,sha256=
|
14
|
+
mdbq/company/copysh.py,sha256=QeTupUdDEVmH0R8lcU3q0SLrhJ-jRyPEJBW1MLmfphI,18358
|
15
15
|
mdbq/company/home_sh.py,sha256=42CZ2tZIXHLl2mOl2gk2fZnjH2IHh1VJ1s3qHABjonY,18021
|
16
16
|
mdbq/config/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
17
17
|
mdbq/config/get_myconf.py,sha256=cmNvsyoNa0RbZ9FOTjSd3jyyGwkxjUo0phvdHbGlrms,6010
|
@@ -31,13 +31,13 @@ mdbq/mysql/year_month_day.py,sha256=VgewoE2pJxK7ErjfviL_SMTN77ki8GVbTUcao3vFUCE,
|
|
31
31
|
mdbq/other/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
32
32
|
mdbq/other/porxy.py,sha256=UHfgEyXugogvXgsG68a7QouUCKaohTKKkI4RN-kYSdQ,4961
|
33
33
|
mdbq/other/pov_city.py,sha256=AEOmCOzOwyjHi9LLZWPKi6DUuSC-_M163664I52u9qw,21050
|
34
|
-
mdbq/other/sku_picture.py,sha256=
|
34
|
+
mdbq/other/sku_picture.py,sha256=GJ_TdIqgjCspZc7z4NQEgjwgyUBj3YGezfaoQtv-3pY,48132
|
35
35
|
mdbq/other/ua_sj.py,sha256=JuVYzc_5QZ9s_oQSrTHVKkQv4S_7-CWx4oIKOARn_9U,22178
|
36
36
|
mdbq/pbix/__init__.py,sha256=Trtfaynu9RjoTyLLYBN2xdRxTvm_zhCniUkVTAYwcjo,24
|
37
37
|
mdbq/pbix/pbix_refresh.py,sha256=JUjKW3bNEyoMVfVfo77UhguvS5AWkixvVhDbw4_MHco,2396
|
38
38
|
mdbq/pbix/refresh_all.py,sha256=0uAnBKCd5cx5FLTkawN1GV9yi87rfyMgYal5LABtumQ,7186
|
39
39
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
40
|
-
mdbq-2.1.
|
41
|
-
mdbq-2.1.
|
42
|
-
mdbq-2.1.
|
43
|
-
mdbq-2.1.
|
40
|
+
mdbq-2.1.4.dist-info/METADATA,sha256=yjtkPOacDIFJ4Cw8FJFxJ521dTVHZLXp_t94FDR4Jk4,245
|
41
|
+
mdbq-2.1.4.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
42
|
+
mdbq-2.1.4.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
43
|
+
mdbq-2.1.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|