新增农行定时
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import requests
|
||||
import ssl
|
||||
import datetime
|
||||
import urllib3
|
||||
from goojia_utils import nextcloudutils, dingutils
|
||||
|
||||
# 禁用 InsecureRequestWarning
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
# 获取当前日期
|
||||
current_date = datetime.datetime.now()
|
||||
# 计算前一日的日期
|
||||
previous_date = current_date - datetime.timedelta(days=1)
|
||||
# 格式化日期
|
||||
formatted_date = previous_date.strftime("%Y.%m.%d")
|
||||
|
||||
data = {
|
||||
"parentCode": "001.002",
|
||||
"dateRange": formatted_date + "," + formatted_date
|
||||
}
|
||||
headers = {
|
||||
"Accept": "*/*",
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhY2NvdW50IjoiYWlyZmxvdyIsImV4cCI6MTMxMzM5NDE2MzQwNDYxLCJvcmdDb2RlIjoiMDAxLjAwMSIsInJvbGVzIjpbIm5vcm1hbCJdLCJ1c2VySWQiOiIxODg5ODc0MDc4MTgxODMwNjU2IiwidXNlcm5hbWUiOiLlrprml7bku7vliqEifQ.SvD42b8XGlxYe_0dBr215ZgxR9aBdsipaySceZuuWR6g5cHelU5oc-dRtK63b0CMoN07BSvh2XYdlIzQ92ngOA"
|
||||
}
|
||||
|
||||
ret = requests.post(url='https://api.fangjia.com/usageStatisticsList', json=data, headers=headers, verify=False)
|
||||
#ret = requests.post(url='http://127.0.0.1:8080/exportStatistics', json=data, headers=headers, verify=False)
|
||||
|
||||
nextcloud_aim_file_path = '共享/AI估价/农行统计'
|
||||
file_path = "AI估价农行" + formatted_date + ".xlsx"
|
||||
with open(file_path, 'wb') as file:
|
||||
# 将字节流写入文件
|
||||
file.write(ret.content)
|
||||
nextcloudutils.up_to_nextcloud(file_path, nextcloud_aim_file_path + "/" + "AI估价农行" + formatted_date + ".xlsx")
|
||||
|
||||
dingutils.send_text("[AI估价]农行" + formatted_date + "统计完成, 请点击 https://nextcloud.fangjia.com/s/WK9MzWwH5kjwMBB 查看", "f4f3b03c35c67d097f70affa27e7d47d7a1b6c0eed2438f4d8aa654834419a0b")
|
||||
@@ -0,0 +1,17 @@
|
||||
from airflow import DAG
|
||||
from airflow.operators.bash import BashOperator
|
||||
import pendulum
|
||||
|
||||
with DAG(
|
||||
dag_id="ai_nonghang_use_dag",
|
||||
# 每天9:40
|
||||
schedule_interval="0 40 9 * * 1-5",
|
||||
start_date=pendulum.datetime(2025, 2, 13, tz="Asia/Shanghai"),
|
||||
description="AI估价农行使用情况",
|
||||
catchup=True
|
||||
) as dag:
|
||||
t1 = BashOperator(
|
||||
task_id='ai_nonghang_use',
|
||||
bash_command='python /opt/airflow/dags/repo/dags/stat/aiprice/nonghang_use.py'
|
||||
)
|
||||
t1
|
||||
Reference in New Issue
Block a user