Refresh report data (manual update)
This commit is contained in:
@@ -23,8 +23,6 @@ CSV_URL = (
|
||||
)
|
||||
TIMEZONE = ZoneInfo("Asia/Shanghai")
|
||||
COUNTRIES = ["KZ", "UZ", "KG", "AM"]
|
||||
# 平台只支持“每隔几小时”,因此按小时调度,仅在此时刻真正更新(Asia/Shanghai)
|
||||
UPDATE_HOUR = 11
|
||||
|
||||
DATE_HEADERS = {"date"}
|
||||
GEO_HEADERS = {"geo", "country"}
|
||||
@@ -245,14 +243,9 @@ def build_payload(rows, now):
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
raise SystemExit("用法: update_report_data.py <输出文件> [--force]")
|
||||
raise SystemExit("用法: update_report_data.py <输出文件>")
|
||||
|
||||
now = datetime.now(TIMEZONE)
|
||||
forced = "--force" in sys.argv[2:]
|
||||
if not forced and now.hour != UPDATE_HOUR:
|
||||
print(f"SKIP {now:%Y-%m-%d %H:%M} 非 {UPDATE_HOUR}:00(Asia/Shanghai),不更新")
|
||||
return
|
||||
|
||||
request = urllib.request.Request(CSV_URL, headers={"User-Agent": "AgentStage-Ozon-Report/2.0"})
|
||||
with urllib.request.urlopen(request, timeout=90) as response:
|
||||
text = response.read().decode("utf-8-sig")
|
||||
|
||||
Reference in New Issue
Block a user