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
4a31fbe6
Commit
4a31fbe6
authored
Oct 23, 2024
by
邱阿朋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
86a8ffe1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
27 deletions
+20
-27
coop.py
coop.py
+5
-3
invoices.py
invoices.py
+12
-15
returns.py
returns.py
+3
-9
No files found.
coop.py
View file @
4a31fbe6
...
...
@@ -3,7 +3,6 @@
import
math
import
os
import
shutil
import
time
from
urllib.parse
import
urlparse
,
parse_qs
import
pandas
as
pd
...
...
@@ -58,7 +57,7 @@ def get_report_table_html(invoice_id):
page
.
ele
(
"#a-autoid-2-announce"
)
.
click
()
# 下载报表
page
.
ele
(
f
"#invoiceDownloads-{invoice_id}_2"
)
.
click
()
time
.
sleep
(
1
)
page
.
wait
(
1
)
# 获取报表表单内容
report_table_html
=
page
.
ele
(
"#backup-report-table"
)
.
html
if
report_table_html
is
None
or
report_table_html
==
""
:
...
...
@@ -199,4 +198,7 @@ def main():
if
__name__
==
'__main__'
:
main
()
try
:
main
()
except
Exception
as
e
:
print
(
e
)
invoices.py
View file @
4a31fbe6
...
...
@@ -2,13 +2,12 @@
# 回款明细
import
os
import
re
import
time
import
urllib.parse
import
warnings
import
pandas
as
pd
from
DrissionPage
import
ChromiumPage
from
DrissionPage.errors
import
PageDisconnectedError
,
ElementNotFoundError
from
DrissionPage.errors
import
ElementNotFoundError
from
lxml
import
etree
from
helper
import
helper
,
excel
,
file
...
...
@@ -69,11 +68,6 @@ def export_list_read_data():
def
export_details_read_data
(
invoice_number
):
# 读取详情内容
file_name
=
f
"invoices
\\
{invoice_number}.csv"
if
os
.
path
.
isfile
(
file_name
):
return
pd
.
read_csv
(
file_name
)
params
=
{
"invoiceNumber"
:
invoice_number
,
"payeeCode"
:
"VECET"
,
...
...
@@ -84,6 +78,11 @@ def export_details_read_data(invoice_number):
full_url
=
f
"https://vendorcentral.amazon.com/hz/vendor/members/inv-mgmt/invoice-details?"
+
query_string
page
.
get
(
full_url
,
timeout
=
3
)
# 读取详情内容
file_name
=
f
"invoices
\\
{invoice_number}.csv"
if
os
.
path
.
isfile
(
file_name
):
return
pd
.
read_csv
(
file_name
)
while
True
:
try
:
page
.
ele
(
"#line-items-export-to-spreadsheet-announce"
,
timeout
=
5
)
.
click
.
to_download
(
rename
=
file_name
)
...
...
@@ -180,7 +179,7 @@ def click_get_price_data():
page
.
ele
(
"#pd"
,
timeout
=
5
)
.
click
()
while
True
:
print
(
"等待争议数据加载,5秒后获取表单数据"
)
time
.
sleep
(
5
)
page
.
wait
(
5
)
try
:
table_html
=
page
.
ele
(
"#priceDiscrepancyWithDMSGridForm"
,
timeout
=
5
)
.
html
price_data
=
price_extract_data
(
table_html
)
...
...
@@ -248,8 +247,8 @@ def main():
invoice_number
=
invoice_number
[:
8
]
# 获取当前订单的Payee和优惠比例
vendor_payment_terms
=
get_po_code
(
i
,
invoice_number
)
time
.
sleep
(
2
)
vendor_payment_terms
=
get_po_code
(
i
,
invoice_number
)
page
.
wait
(
2
)
print
(
vendor_payment_terms
)
vendor
=
vendor_payment_terms
[
'vendor'
]
...
...
@@ -257,7 +256,7 @@ def main():
# 下载excel文件并读取数据
detail_data
=
export_details_read_data
(
invoice_number
)
time
.
sleep
(
2
)
page
.
wait
(
2
)
# 获取争议数据
all_price_data
=
click_get_price_data
()
...
...
@@ -299,7 +298,5 @@ def main():
if
__name__
==
'__main__'
:
try
:
main
()
except
KeyboardInterrupt
:
pass
except
PageDisconnectedError
as
e
:
print
(
"与页面的连接已断开"
)
except
Exception
as
e
:
print
(
e
)
returns.py
View file @
4a31fbe6
...
...
@@ -4,7 +4,7 @@ import os
import
pandas
as
pd
from
DrissionPage
import
ChromiumPage
from
DrissionPage.errors
import
PageDisconnectedError
,
ElementNotFoundError
from
DrissionPage.errors
import
ElementNotFoundError
from
helper
import
helper
,
excel
,
file
...
...
@@ -113,12 +113,6 @@ 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}")
main
()
except
KeyboardInterrupt
:
pass
except
PageDisconnectedError
as
e
:
print
(
"与页面的连接已断开"
)
except
Exception
as
e
:
print
(
e
)
\ No newline at end of file
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