mdbq 1.8.2__py3-none-any.whl → 1.8.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/other/sku_picture.py
CHANGED
@@ -32,6 +32,7 @@ warnings.filterwarnings('ignore')
|
|
32
32
|
|
33
33
|
if platform.system() == 'Windows':
|
34
34
|
Share_Path = os.path.join(r'\\192.168.1.198\时尚事业部\01.运营部\天猫报表') # 共享文件根目录
|
35
|
+
# Share_Path = os.path.join(r'\\192.168.1.198\时尚事业部\01.运营部\天猫报表') # 共享文件根目录
|
35
36
|
elif platform.system() == 'Darwin':
|
36
37
|
Share_Path = os.path.join('/Volumes/时尚事业部/01.运营部/天猫报表') # 共享文件根目录
|
37
38
|
else:
|
@@ -533,42 +534,8 @@ class DownloadPicture():
|
|
533
534
|
start_date = f'{start_date.year}-{start_date.month}-01' # 替换为 n 月以前的第一天
|
534
535
|
return pd.to_datetime(start_date), pd.to_datetime(end_date)
|
535
536
|
|
536
|
-
def main(service_name, database):
|
537
|
-
if not os.path.exists(Share_Path):
|
538
|
-
print(f'当前系统环境不支持')
|
539
|
-
return
|
540
|
-
|
541
|
-
_driver = LoadAccount() # 账号域不同, 要重新实例化
|
542
|
-
# tb_driver2 = 1
|
543
|
-
tb_driver2 = _driver.load_account(shop_name='万里马官方旗舰店')
|
544
|
-
if tb_driver2:
|
545
|
-
s = SkuPicture(driver=tb_driver2)
|
546
|
-
s.read_df() # 从本地文件中读取商品id,并更新 urls 参数
|
547
|
-
s.each_page() # 根据 urls 获取每个商品数据并更新为 df
|
548
|
-
tb_driver2.quit()
|
549
537
|
|
550
|
-
|
551
|
-
username, password, host, port = get_myconf.select_config_values(target_service=service_name, database=database)
|
552
|
-
m = mysql.MysqlUpload(username=username, password=password, host=host, port=port)
|
553
|
-
m.df_to_mysql(
|
554
|
-
df=s.df,
|
555
|
-
db_name='属性设置2',
|
556
|
-
table_name='天猫商品sku信息',
|
557
|
-
move_insert=True, # 先删除,再插入
|
558
|
-
# df_sql=True,
|
559
|
-
# drop_duplicates=False,
|
560
|
-
# icm_update=unique_key_list,
|
561
|
-
service_database={service_name: database},
|
562
|
-
) # 3. 回传数据库
|
563
|
-
|
564
|
-
|
565
|
-
def main2(service_name, database):
|
566
|
-
d = DownloadPicture(service_name=service_name)
|
567
|
-
d.get_df_from_service()
|
568
|
-
d.download_data()
|
569
|
-
|
570
|
-
|
571
|
-
class InsertPicture():
|
538
|
+
class InsertPicture:
|
572
539
|
def __init__(self):
|
573
540
|
self.filename = 'test.xlsx'
|
574
541
|
self.path = '/Users/xigua/Downloads'
|
@@ -666,7 +633,7 @@ class InsertPicture():
|
|
666
633
|
break # 商品id只需要添加一次,所以必须 break,否则可能添加多个图片到某个单元格
|
667
634
|
|
668
635
|
if is_trange == False:
|
669
|
-
print(f'{self.filename}:\n'
|
636
|
+
print(f'{os.path.join(self.path, self.filename)}:\n'
|
670
637
|
f'在该文件中没有找到匹配的 skuid/商品id/商家编码, 注意程序只会转换当前活动的 sheet, \n'
|
671
638
|
f'1. 如果您确定文件中确实存在 skuid/商品id/商家编码, 可能是因为 sheet 不是活动状态, 请切换后再重新运行本程序。\n'
|
672
639
|
f'2. 程序只能转换已经收录的商品图, 如果未被收录亦会转换失败, 请联系开发者添加。')
|
@@ -706,15 +673,54 @@ class InsertPicture():
|
|
706
673
|
)
|
707
674
|
|
708
675
|
|
676
|
+
def main(service_name, database):
|
677
|
+
""" 从 excel 获取商品id,通过爬虫获取 sku 图片数据并存入数据库 """
|
678
|
+
if not os.path.exists(Share_Path):
|
679
|
+
print(f'当前系统环境不支持')
|
680
|
+
return
|
681
|
+
|
682
|
+
_driver = LoadAccount() # 账号域不同, 要重新实例化
|
683
|
+
# tb_driver2 = 1
|
684
|
+
tb_driver2 = _driver.load_account(shop_name='万里马官方旗舰店')
|
685
|
+
if tb_driver2:
|
686
|
+
s = SkuPicture(driver=tb_driver2)
|
687
|
+
s.path = os.path.join(Share_Path, '其他文件') # 本地 excel 的路径
|
688
|
+
s.filename = '商品id编码表.xlsx'
|
689
|
+
s.read_df() # 从本地文件中读取商品id,并更新 urls 参数
|
690
|
+
s.each_page() # 根据 urls 获取每个商品数据并更新为 df
|
691
|
+
tb_driver2.quit()
|
692
|
+
|
693
|
+
# s.df.to_csv('/Users/xigua/Downloads/test.csv', encoding='utf-8_sig', index=False, header=True)
|
694
|
+
username, password, host, port = get_myconf.select_config_values(target_service=service_name, database=database)
|
695
|
+
m = mysql.MysqlUpload(username=username, password=password, host=host, port=port)
|
696
|
+
m.df_to_mysql(
|
697
|
+
df=s.df,
|
698
|
+
db_name='属性设置2',
|
699
|
+
table_name='天猫商品sku信息',
|
700
|
+
move_insert=True, # 先删除,再插入
|
701
|
+
# df_sql=True,
|
702
|
+
# drop_duplicates=False,
|
703
|
+
# icm_update=unique_key_list,
|
704
|
+
service_database={service_name: database},
|
705
|
+
) # 3. 回传数据库
|
706
|
+
|
707
|
+
|
708
|
+
def main2(service_name, database):
|
709
|
+
""" 从数据库读取数据,并下载图片到本地 """
|
710
|
+
d = DownloadPicture(service_name=service_name)
|
711
|
+
d.get_df_from_service()
|
712
|
+
d.download_data()
|
713
|
+
|
714
|
+
|
709
715
|
def main3():
|
710
716
|
p = InsertPicture()
|
711
|
-
p.filename = '
|
717
|
+
p.filename = 'test.xlsx'
|
712
718
|
# p.header = 1
|
713
719
|
p.insert_data()
|
714
720
|
|
715
721
|
|
716
722
|
|
717
723
|
if __name__ == '__main__':
|
718
|
-
|
719
|
-
# main2(service_name='
|
720
|
-
main3()
|
724
|
+
main(service_name='home_lx', database='mysql')
|
725
|
+
# main2(service_name='home_lx', database='mysql')
|
726
|
+
# main3()
|
@@ -30,13 +30,13 @@ mdbq/mysql/year_month_day.py,sha256=VgewoE2pJxK7ErjfviL_SMTN77ki8GVbTUcao3vFUCE,
|
|
30
30
|
mdbq/other/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
31
31
|
mdbq/other/porxy.py,sha256=UHfgEyXugogvXgsG68a7QouUCKaohTKKkI4RN-kYSdQ,4961
|
32
32
|
mdbq/other/pov_city.py,sha256=AEOmCOzOwyjHi9LLZWPKi6DUuSC-_M163664I52u9qw,21050
|
33
|
-
mdbq/other/sku_picture.py,sha256=
|
33
|
+
mdbq/other/sku_picture.py,sha256=lLWKC6FZlRye_NMo5fh9vDJyb7ZKqj4PUt8YrOldZQg,33856
|
34
34
|
mdbq/other/ua_sj.py,sha256=JuVYzc_5QZ9s_oQSrTHVKkQv4S_7-CWx4oIKOARn_9U,22178
|
35
35
|
mdbq/pbix/__init__.py,sha256=Trtfaynu9RjoTyLLYBN2xdRxTvm_zhCniUkVTAYwcjo,24
|
36
36
|
mdbq/pbix/pbix_refresh.py,sha256=JUjKW3bNEyoMVfVfo77UhguvS5AWkixvVhDbw4_MHco,2396
|
37
37
|
mdbq/pbix/refresh_all.py,sha256=0uAnBKCd5cx5FLTkawN1GV9yi87rfyMgYal5LABtumQ,7186
|
38
38
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
39
|
-
mdbq-1.8.
|
40
|
-
mdbq-1.8.
|
41
|
-
mdbq-1.8.
|
42
|
-
mdbq-1.8.
|
39
|
+
mdbq-1.8.4.dist-info/METADATA,sha256=rrJRQbwrw7Yd5rbYV_a8jf2oFeLVUHKbuvHjY3aSgto,245
|
40
|
+
mdbq-1.8.4.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
|
41
|
+
mdbq-1.8.4.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
42
|
+
mdbq-1.8.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|