Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amazon_reports
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
common
amazon_reports
Commits
e64a0c56
Commit
e64a0c56
authored
Oct 22, 2024
by
邱阿朋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理
parent
8723ce3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
38 deletions
+50
-38
coop.py
coop.py
+10
-9
invoices.py
invoices.py
+10
-9
returns.py
returns.py
+30
-20
No files found.
coop.py
View file @
e64a0c56
...
...
@@ -25,7 +25,7 @@ helper.make_dir(download_path)
page
.
set
.
download_path
(
download_path
)
def
asin_
sku_relations
():
def
sku_relations
():
relations_dict
=
{}
df
=
pd
.
read_excel
(
'relations.xlsx'
)
for
index
,
row
in
df
.
iterrows
():
...
...
@@ -38,13 +38,14 @@ def asin_sku_relations():
def
export_list_read_data
():
file_name
=
"ContraCogsInvoices.xls"
if
not
os
.
path
.
isfile
(
file_name
):
page
.
get
(
"https://vendorcentral.amazon.com/hz/vendor/members/coop?ref_=vc_xx_subNav"
)
# 全选
page
.
ele
(
"#select-all"
)
.
click
()
# 点击选项卡
page
.
ele
(
"#cc-invoice-actions-dropdown"
)
.
click
()
# 点击下载报表
page
.
ele
(
"#cc-invoice-actions-dropdown_2"
)
.
click
.
to_download
()
.
wait
()
raise
FileNotFoundError
(
f
"{file_name},文件不存在"
)
# page.get("https://vendorcentral.amazon.com/hz/vendor/members/coop?ref_=vc_xx_subNav")
# # 全选
# page.ele("#select-all").click()
# # 点击选项卡
# page.ele("#cc-invoice-actions-dropdown").click()
# # 点击下载报表
# page.ele("#cc-invoice-actions-dropdown_2").click.to_download().wait()
return
pd
.
read_excel
(
file_name
,
engine
=
'xlrd'
)
...
...
@@ -112,7 +113,7 @@ def export_item_read_data(invoice_id):
def
main
():
relation_data
=
asin_
sku_relations
()
# 获取 ASIN 与 SKU 的对应关系数据
relation_data
=
sku_relations
()
# 获取 ASIN 与 SKU 的对应关系数据
coop_list
=
export_list_read_data
()
# 获取合作数据列表
coop_list
=
coop_list
[:
10
]
print
(
f
"共计:{len(coop_list)} 条数据"
)
...
...
invoices.py
View file @
e64a0c56
...
...
@@ -28,14 +28,18 @@ warnings.filterwarnings("ignore", category=UserWarning, module="openpyxl")
def
export_list_read_data
():
file_name
=
'new_Payments.xlsx'
if
os
.
path
.
isfile
(
file_name
):
df
=
pd
.
read_excel
(
file_name
)
new_
file_name
=
'new_Payments.xlsx'
if
os
.
path
.
isfile
(
new_
file_name
):
df
=
pd
.
read_excel
(
new_
file_name
)
return
df
page
.
get
(
f
"https://vendorcentral.amazon.com/hz/vendor/members/remittance/home"
,
timeout
=
3
)
page
.
ele
(
"#remittance-home-select-all"
,
timeout
=
2
)
.
click
()
page
.
ele
(
"#remittance-home-export-link"
,
timeout
=
2
)
.
click
.
to_download
()
file_name
=
'new_Payments.xlsx'
if
not
os
.
path
.
isfile
(
new_file_name
):
raise
FileNotFoundError
(
f
"{file_name},文件不存在"
)
# page.get(f"https://vendorcentral.amazon.com/hz/vendor/members/remittance/home", timeout=3)
# page.ele("#remittance-home-select-all", timeout=2).click()
# page.ele("#remittance-home-export-link", timeout=2).click.to_download()
# file.wait_for_downloads(file_name)
all_df
=
pd
.
read_excel
(
'Payments.xlsx'
,
header
=
None
)
...
...
@@ -86,9 +90,6 @@ def export_details_read_data(invoice_number):
page
.
refresh
()
export_details_read_data
(
invoice_number
)
if
not
os
.
path
.
isfile
(
file_name
):
export_details_read_data
(
invoice_number
)
return
pd
.
read_csv
(
file_name
)
...
...
returns.py
View file @
e64a0c56
...
...
@@ -5,9 +5,9 @@ import time
import
pandas
as
pd
from
DrissionPage
import
ChromiumPage
from
DrissionPage.errors
import
PageDisconnectedError
from
DrissionPage.errors
import
PageDisconnectedError
,
ElementNotFoundError
from
helper
import
helper
,
excel
,
file
from
helper
import
helper
,
excel
,
file
email
=
None
password
=
None
...
...
@@ -47,10 +47,14 @@ def open_url(url):
# todo 识别图形码
def
asin_
sku_relations
():
def
sku_relations
():
relations_dict
=
{}
# 读取ASIN和sku映射关系
df
=
pd
.
read_excel
(
'relations.xlsx'
)
file_name
=
'relations.xlsx'
if
not
os
.
path
.
isfile
(
file_name
):
raise
FileNotFoundError
(
f
"{file_name},请确认sku关系文件不存在"
)
df
=
pd
.
read_excel
(
file_name
)
for
index
,
row
in
df
.
iterrows
():
row_dict
=
row
.
to_dict
()
relations_dict
[
row_dict
[
'ASIN'
]]
=
row_dict
[
'SKU'
]
...
...
@@ -61,11 +65,12 @@ def asin_sku_relations():
def
export_list_read_data
():
file_name
=
"Return_Summary.xls"
if
not
os
.
path
.
isfile
(
file_name
):
# 访问网页
open_url
(
"https://vendorcentral.amazon.com/hz/vendor/members/returns?ref_=vc_xx_subNav"
)
# 导出退货单
page
.
ele
(
"#file-download-button"
)
.
click
.
to_download
()
file
.
wait_for_downloads
(
file_name
)
raise
FileNotFoundError
(
f
"{file_name},文件不存在"
)
# # 访问网页
# open_url("https://vendorcentral.amazon.com/hz/vendor/members/returns?ref_=vc_xx_subNav")
# # 导出退货单
# page.ele("#file-download-button").click.to_download()
# file.wait_for_downloads(file_name)
return
pd
.
read_excel
(
file_name
,
engine
=
'xlrd'
)
...
...
@@ -73,18 +78,24 @@ def export_list_read_data():
def
export_item_read_data
(
return_id
):
file_name
=
f
"returns
\\
{return_id}.xls"
if
not
os
.
path
.
isfile
(
file_name
):
# 打开退回详情下载明细
open_url
(
f
"https://vendorcentral.amazon.com/katalmonsapp/vendor/members/returns/{return_id}"
)
page
.
ele
(
"#file-download-button"
)
.
click
.
to_download
(
rename
=
file_name
)
file
.
wait_for_downloads
(
file_name
)
while
True
:
try
:
# 打开退回详情下载明细
open_url
(
f
"https://vendorcentral.amazon.com/katalmonsapp/vendor/members/returns/{return_id}"
)
page
.
ele
(
"#file-download-button"
)
.
click
.
to_download
(
rename
=
file_name
)
file
.
wait_for_downloads
(
file_name
)
break
except
ElementNotFoundError
:
print
(
"元素未找到,刷新网页"
)
page
.
refresh
()
# 读取回退商品详情
return
pd
.
read_excel
(
file_name
,
engine
=
'xlrd'
)
def
main
():
# 读取
asin和
sku映射关系
relations_dict
=
asin_
sku_relations
()
# 读取sku映射关系
relations_dict
=
sku_relations
()
# 下载并读取list数据
list_data
=
export_list_read_data
()
...
...
@@ -122,11 +133,10 @@ def main():
if
__name__
==
'__main__'
:
try
:
email
=
helper
.
get_input_with_default
(
"请输入账户"
,
"us-cs001@khdtek.com"
)
print
(
f
"您输入的账户是:{email}"
)
password
=
helper
.
get_input_with_default
(
"请输入密码"
,
"khd=20221208"
)
print
(
f
"您输入的密码是:{password}"
)
# email = helper.get_input_with_default("请输入账户", "us-cs001@khdtek.com")
# print(f"您输入的账户是:{email}")
# password = helper.get_input_with_default("请输入密码", "khd=20221208")
# print(f"您输入的密码是:{password}")
main
()
except
KeyboardInterrupt
:
pass
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment