Spaces:
Sleeping
Sleeping
import streamlit as st | |
import schedule | |
import time | |
import subprocess | |
import threading | |
# Function to execute your scripts | |
def job(): | |
st.write("スクリプト実行完了") | |
subprocess.run(["python", "scrap_data_from_FN.py"]) | |
time.sleep(20) | |
subprocess.run(["python", "run_at_morning.py"]) | |
st.write("作業完了") | |
# Schedule the job at 04:00 AM daily | |
schedule.every().day.at("04:00").do(job) | |
# Background scheduler function | |
def run_scheduler(): | |
while True: | |
schedule.run_pending() | |
time.sleep(60) | |
# Start the scheduler in a separate thread | |
threading.Thread(target=run_scheduler, daemon=True).start() | |
# Streamlit UI | |
st.title("FN スクレイピングアプリ") | |
st.write("アプリは午前4時に自動で回るように設定されています。") | |
if st.button("実行"): | |
job() | |
st.success("手動実行") | |