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
1a569537
Commit
1a569537
authored
Oct 22, 2024
by
邱阿朋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理
parent
f64bbdde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
26 deletions
+33
-26
coop.py
coop.py
+20
-16
invoices.py
invoices.py
+13
-10
No files found.
coop.py
View file @
1a569537
...
...
@@ -50,20 +50,24 @@ def export_list_read_data():
def
get_report_table_html
(
invoice_id
):
page
.
get
(
f
"https://vendorcentral.amazon.com/hz/vendor/members/coop?searchText={invoice_id}"
)
try
:
# 点击选项卡
page
.
ele
(
"#a-autoid-2-announce"
)
.
click
()
# 下载报表
page
.
ele
(
f
"#invoiceDownloads-{invoice_id}_2"
)
.
click
()
time
.
sleep
(
1
)
# 获取报表表单内容
report_table_html
=
page
.
ele
(
"#backup-report-table"
)
.
html
return
report_table_html
except
ElementNotFoundError
:
page
.
refresh
()
get_report_table_html
(
invoice_id
)
while
True
:
try
:
page
.
get
(
f
"https://vendorcentral.amazon.com/hz/vendor/members/coop?searchText={invoice_id}"
)
# 点击选项卡
page
.
ele
(
"#a-autoid-2-announce"
)
.
click
()
# 下载报表
page
.
ele
(
f
"#invoiceDownloads-{invoice_id}_2"
)
.
click
()
time
.
sleep
(
1
)
# 获取报表表单内容
report_table_html
=
page
.
ele
(
"#backup-report-table"
)
.
html
if
report_table_html
is
None
or
report_table_html
==
""
:
print
(
"表单内容为空,刷新网页"
)
page
.
refresh
()
continue
return
report_table_html
except
ElementNotFoundError
:
print
(
"元素未找到,刷新网页"
)
page
.
refresh
()
def
export_item_read_data
(
invoice_id
):
file_name
=
f
"coop
\\
{invoice_id}.xlsx"
...
...
@@ -110,7 +114,7 @@ def export_item_read_data(invoice_id):
def
main
():
relation_data
=
asin_sku_relations
()
# 获取 ASIN 与 SKU 的对应关系数据
coop_list
=
export_list_read_data
()
# 获取合作数据列表
#
coop_list = coop_list[:10]
coop_list
=
coop_list
[:
10
]
print
(
f
"共计:{len(coop_list)},条数据"
)
i
=
0
...
...
@@ -180,7 +184,7 @@ def main():
if
sheet_data
:
# 循环遍历 sheet_data 字典
for
key
,
value
in
sheet_data
.
items
():
if
len
(
value
)
>
10
000
:
if
len
(
value
)
>
5
000
:
max_sheet_data
[
key
]
=
value
continue
...
...
invoices.py
View file @
1a569537
...
...
@@ -29,18 +29,22 @@ warnings.filterwarnings("ignore", category=UserWarning, module="openpyxl")
def
export_list_read_data
():
file_name
=
'Payments.xlsx'
if
not
os
.
path
.
isfile
(
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
)
if
os
.
path
.
isfile
(
file_name
):
df
=
pd
.
read_excel
(
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
.
wait_for_downloads
(
file_name
)
df
=
pd
.
read_excel
(
file_name
,
skiprows
=
2
2
)
df
=
pd
.
read_excel
(
file_name
,
skiprows
=
2
1
)
# 定义正则表达式模式,匹配包含 'Price' 或 'PCR' 或 'XXXXXXXX/XXXX/' 的描述
pattern
=
r'Price Claim|PCR|Missed Adjustment|Shortage Claim|^[A-Z0-9]{8}/[A-Z0-9]{4}/'
# 过滤符合条件的行
return
df
[
df
[
'Description'
]
.
str
.
contains
(
pattern
,
na
=
False
,
regex
=
True
)]
data
=
df
[
df
[
'Description'
]
.
str
.
contains
(
pattern
,
na
=
False
,
regex
=
True
)]
excel
.
save_xls
(
data
,
"Payments.xlsx"
,
"Remittance payments"
)
return
df
def
export_details_read_data
(
invoice_number
):
# 读取详情内容
...
...
@@ -55,7 +59,7 @@ def export_details_read_data(invoice_number):
# 将字典转换为 URL 查询参数
query_string
=
urllib
.
parse
.
urlencode
(
params
)
page
.
get
(
f
"https://vendorcentral.amazon.com/hz/vendor/members/inv-mgmt/invoice-details"
+
query_string
)
f
"https://vendorcentral.amazon.com/hz/vendor/members/inv-mgmt/invoice-details
?
"
+
query_string
)
if
not
os
.
path
.
isfile
(
file_name
):
page
.
ele
(
"#line-items-export-to-spreadsheet-announce"
,
timeout
=
5
)
.
click
.
to_download
(
rename
=
file_name
)
...
...
@@ -212,7 +216,6 @@ def handle_data(detail_datum, vendor, deduction_points):
def
main
():
list_data
=
export_list_read_data
()
excel
.
save_xls
(
list_data
,
"回款数据.xlsx"
,
"Remittance payments"
)
# list_data = list_data[62:]
print
(
f
"共计:{len(list_data)} 订单"
)
all_normal_pay_data
=
[]
...
...
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