remove scheduler.py
This commit is contained in:
51
scheduler.py
51
scheduler.py
@@ -1,51 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
Scheduler script for Flat Scraper
|
|
||||||
Runs every 6 hours and sends notifications for new results
|
|
||||||
"""
|
|
||||||
|
|
||||||
import schedule
|
|
||||||
import time
|
|
||||||
import logging
|
|
||||||
from src.main import FlatScraper
|
|
||||||
|
|
||||||
# Configure logging
|
|
||||||
logging.basicConfig(
|
|
||||||
level=logging.INFO,
|
|
||||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
||||||
)
|
|
||||||
|
|
||||||
def run_scraper():
|
|
||||||
"""Run the scraper once"""
|
|
||||||
try:
|
|
||||||
scraper = FlatScraper()
|
|
||||||
scraper.run_once()
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"Error running scraper: {e}")
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""Main scheduler function"""
|
|
||||||
print('🕐 Scheduler started. Running every 6 hours.')
|
|
||||||
print('🏠 Flat Scraper will check for new apartments automatically.')
|
|
||||||
|
|
||||||
# Schedule every 6 hours
|
|
||||||
schedule.every(6).hours.do(run_scraper)
|
|
||||||
|
|
||||||
# Run immediately on start
|
|
||||||
print('🚀 Running initial scrape...')
|
|
||||||
run_scraper()
|
|
||||||
|
|
||||||
# Keep running
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
schedule.run_pending()
|
|
||||||
time.sleep(60) # Check every minute
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print('\n👋 Scheduler stopped by user.')
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"Scheduler error: {e}")
|
|
||||||
time.sleep(300) # Wait 5 minutes on error
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user