Commit 86a8ffe1 authored by 邱阿朋's avatar 邱阿朋

优化

parent d14da127
...@@ -60,7 +60,8 @@ def export_list_read_data(): ...@@ -60,7 +60,8 @@ def export_list_read_data():
# 过滤符合条件的行 # 过滤符合条件的行
filtered_second_df = second_df[second_df['Description'].str.contains(pattern, na=False, regex=True)] filtered_second_df = second_df[second_df['Description'].str.contains(pattern, na=False, regex=True)]
merged_df = pd.merge(filtered_second_df, first_df[['Payment Number', 'Payment Date']], on='Payment Number',how='left') merged_df = pd.merge(filtered_second_df, first_df[['Payment Number', 'Payment Date']], on='Payment Number',
how='left')
excel.save_xls(merged_df, new_file_name, "Remittance payments") excel.save_xls(merged_df, new_file_name, "Remittance payments")
...@@ -70,27 +71,28 @@ def export_list_read_data(): ...@@ -70,27 +71,28 @@ def export_list_read_data():
def export_details_read_data(invoice_number): def export_details_read_data(invoice_number):
# 读取详情内容 # 读取详情内容
file_name = f"invoices\\{invoice_number}.csv" file_name = f"invoices\\{invoice_number}.csv"
if os.path.isfile(file_name):
return pd.read_csv(file_name)
try: params = {
params = { "invoiceNumber": invoice_number,
"invoiceNumber": invoice_number, "payeeCode": "VECET",
"payeeCode": "VECET", "activeTab": "lineItems",
"activeTab": "lineItems", }
} # 将字典转换为 URL 查询参数
# 将字典转换为 URL 查询参数 query_string = urllib.parse.urlencode(params)
query_string = urllib.parse.urlencode(params) full_url = f"https://vendorcentral.amazon.com/hz/vendor/members/inv-mgmt/invoice-details?" + query_string
page.get( page.get(full_url, timeout=3)
f"https://vendorcentral.amazon.com/hz/vendor/members/inv-mgmt/invoice-details?" + query_string)
if not os.path.isfile(file_name): while True:
try:
page.ele("#line-items-export-to-spreadsheet-announce", timeout=5).click.to_download(rename=file_name) page.ele("#line-items-export-to-spreadsheet-announce", timeout=5).click.to_download(rename=file_name)
file.wait_for_downloads(file_name) file.wait_for_downloads(file_name)
excel.remove_last_comma(file_name) excel.remove_last_comma(file_name)
break
except ElementNotFoundError: except ElementNotFoundError:
print("导出按钮不存在刷新网页") print("导出按钮不存在刷新网页")
page.refresh() page.refresh()
export_details_read_data(invoice_number)
return pd.read_csv(file_name) return pd.read_csv(file_name)
......
# coding: utf-8 # coding: utf-8
# 导出退款记录 # 导出退款记录
import os import os
import time
import pandas as pd import pandas as pd
from DrissionPage import ChromiumPage from DrissionPage import ChromiumPage
...@@ -24,29 +23,6 @@ helper.make_dir(download_path) ...@@ -24,29 +23,6 @@ helper.make_dir(download_path)
page.set.download_path(download_path) page.set.download_path(download_path)
def open_url(url):
# 访问网页
page.get(url, timeout=5)
time.sleep(1)
element = page.ele('#ap_email', timeout=1)
if element:
page.ele('#ap_email').input(email)
page.ele('#continue').click()
page.ele('#ap_password').input(password)
page.ele('#signInSubmit').click()
# 判断是否有图形码
while True:
time.sleep(1)
if not page.ele('.a-section a-text-center cvf-captcha-img'):
break
print("请填入图形码内容")
# todo 识别图形码
def sku_relations(): def sku_relations():
relations_dict = {} relations_dict = {}
# 读取ASIN和sku映射关系 # 读取ASIN和sku映射关系
...@@ -67,7 +43,7 @@ def export_list_read_data(): ...@@ -67,7 +43,7 @@ def export_list_read_data():
if not os.path.isfile(file_name): if not os.path.isfile(file_name):
# raise FileNotFoundError(f"{file_name},文件不存在") # raise FileNotFoundError(f"{file_name},文件不存在")
# 访问网页 # 访问网页
open_url("https://vendorcentral.amazon.com/hz/vendor/members/returns?ref_=vc_xx_subNav") page.get("https://vendorcentral.amazon.com/hz/vendor/members/returns?ref_=vc_xx_subNav", timeout=3)
# 导出退货单 # 导出退货单
page.ele("#file-download-button").click.to_download() page.ele("#file-download-button").click.to_download()
file.wait_for_downloads(file_name) file.wait_for_downloads(file_name)
...@@ -81,7 +57,7 @@ def export_item_read_data(return_id): ...@@ -81,7 +57,7 @@ def export_item_read_data(return_id):
while True: while True:
try: try:
# 打开退回详情下载明细 # 打开退回详情下载明细
open_url(f"https://vendorcentral.amazon.com/katalmonsapp/vendor/members/returns/{return_id}") page.get(f"https://vendorcentral.amazon.com/katalmonsapp/vendor/members/returns/{return_id}", timeout=3)
page.ele("#file-download-button").click.to_download(rename=file_name) page.ele("#file-download-button").click.to_download(rename=file_name)
file.wait_for_downloads(file_name) file.wait_for_downloads(file_name)
break break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment