69 lines
2.4 KiB
Python
69 lines
2.4 KiB
Python
import os
|
|
from dotenv import load_dotenv
|
|
# We import directly from main to reuse the already configured functions
|
|
from main import setup_driver, login, get_jobs_list
|
|
|
|
def run_debug():
|
|
"""
|
|
Runs the scraper logic directly for debugging purposes inside the container.
|
|
"""
|
|
load_dotenv()
|
|
print("--- Starting Standalone Scraper Debug ---")
|
|
|
|
# --- Configuration ---
|
|
# Change this to 'schule' to test the other account
|
|
ACCOUNT_TO_TEST = "kiga"
|
|
|
|
username = os.getenv(f"{ACCOUNT_TO_TEST.upper()}_USER")
|
|
password = os.getenv(f"{ACCOUNT_TO_TEST.upper()}_PW")
|
|
|
|
if not username or not password:
|
|
print(f"!!! FATAL ERROR: Credentials for {ACCOUNT_TO_TEST} not found in .env file.")
|
|
print("Please ensure KIGA_USER, KIGA_PW, etc. are set correctly.")
|
|
return
|
|
|
|
print(f"Attempting to log in with user: {username}")
|
|
|
|
driver = None
|
|
try:
|
|
driver = setup_driver()
|
|
if not driver:
|
|
print("!!! FATAL ERROR: WebDriver initialization failed.")
|
|
return
|
|
|
|
# Perform the login
|
|
if login(driver, username, password):
|
|
print("\n✅ LOGIN SUCCESSFUL!")
|
|
print("-----------------------------------------")
|
|
print("Now attempting to fetch jobs from the dashboard...")
|
|
|
|
# Fetch the jobs
|
|
jobs = get_jobs_list(driver)
|
|
|
|
if jobs:
|
|
print(f"\n✅ SUCCESS: Found {len(jobs)} jobs!")
|
|
for i, job in enumerate(jobs):
|
|
print(f" {i+1}. Name: {job['name']}")
|
|
print(f" Status: {job['status']}")
|
|
print(f" Date: {job['date']}")
|
|
else:
|
|
print("\n⚠️ WARNING: Login seemed successful, but no jobs were found on the dashboard.")
|
|
print("This could be due to incorrect page selectors for the job list.")
|
|
|
|
else:
|
|
print("\n❌ LOGIN FAILED.")
|
|
print("Please check credentials in .env and the login selectors in main.py.")
|
|
print("A screenshot of the error might have been saved if the scraper has permission.")
|
|
|
|
except Exception as e:
|
|
print(f"\n\n!!! AN UNEXPECTED ERROR OCCURRED: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
finally:
|
|
if driver:
|
|
print("\n--- Debug script finished. Closing WebDriver. ---")
|
|
driver.quit()
|
|
|
|
if __name__ == "__main__":
|
|
run_debug()
|