# Property Availability Checker - Quick Start

## ⚡ Quick Start (5 minutes)

### 1. First Run - Check All Properties

```bash
cd "/Users/jonathan/SynologyDrive/Since Today/PROJECTEN/farmmatch/scraper"
python3 check_availability.py
```

**What it does:**
- ✅ Checks all 186 properties
- ✅ Marks unavailable ones as "Removed"
- ✅ Skips properties checked in last 24 hours
- ✅ Takes ~6-10 minutes (2 seconds per property)
- ✅ Creates `availability_check_report.json`

### 2. Review Results

Check the summary at the end:
```
📊 AVAILABILITY CHECK SUMMARY
Total properties: 186
✅ Still available: 175
❌ Newly unavailable: 11
```

View in map viewer: [http://localhost:8000/map_viewer_advanced.html](http://localhost:8000/map_viewer_advanced.html)
- Removed properties are hidden by default
- Toggle "Show Removed Properties" to see them

### 3. Permanently Remove (Optional)

```bash
python3 check_availability.py --remove
```

**What it does:**
- ✅ Creates backup before removing
- ✅ Asks for confirmation
- ✅ Permanently deletes unavailable properties from JSON

### 4. Set Up Daily Automation

```bash
# Option 1: Python scheduler (simple)
nohup python3 auto_availability_check.py > availability_checker.log 2>&1 &

# Option 2: macOS Launchd (system-level)
# See AVAILABILITY_CHECKER_GUIDE.md for full instructions
```

## 🎯 Common Commands

```bash
# Check all (skip recently checked)
python3 check_availability.py

# Force check ALL properties
python3 check_availability.py --force

# Remove unavailable properties permanently
python3 check_availability.py --remove

# Start daily scheduler (3 AM)
python3 auto_availability_check.py

# View reports
cat availability_check_report.json
```

## 📊 Understanding the Output

### During Check:
```
[50/186] Saint-Just
   URL: https://www.properstar.nl/listing/103499163
   Current status: Active
   🔍 Checking availability...
   ✅ Available - Property appears to be active
```

or

```
[75/186] Les Useres
   URL: https://www.properstar.nl/listing/86083770
   Current status: Active
   🔍 Checking availability...
   ❌ UNAVAILABLE - Page not found (404)
   📝 Marked as 'Removed'
```

### Report (availability_check_report.json):
```json
{
  "timestamp": "2025-10-08T19:30:00",
  "total_properties": 186,
  "checked": 186,
  "still_available": 175,
  "newly_unavailable": 11,
  "availability_rate": "94.1%"
}
```

## 🔄 Recommended Workflow

### Daily (Automated):
1. **3:00 AM** - Auto-check runs (`auto_availability_check.py`)
2. Properties marked as "Removed" automatically
3. Map viewer filters them out

### Weekly (Manual):
```bash
# Sunday - Clean up removed properties
python3 check_availability.py --remove
```

### Monthly (Manual):
```bash
# Force full recheck
python3 check_availability.py --force
```

## ⚠️ Important Notes

1. **Rate Limiting**: 2 seconds between requests (respects servers)
2. **Smart Caching**: Won't recheck properties checked in last 24 hours (use `--force` to override)
3. **Backup Always**: `--remove` creates backup before deleting
4. **Conservative**: If uncertain, assumes property is available
5. **Integration**: Map viewer already hides removed properties

## 🐛 Troubleshooting

**Properties not being checked?**
→ Already checked in last 24h. Use `--force` to recheck.

**Too many false positives?**
→ Check `availability_reason` field in enriched_data.json

**Script taking too long?**
→ Normal! ~6-10 minutes for 186 properties. Saves progress every 10 properties.

## 📚 Full Documentation

See [AVAILABILITY_CHECKER_GUIDE.md](AVAILABILITY_CHECKER_GUIDE.md) for:
- Advanced configuration
- Custom detection keywords
- Scheduling options (cron, launchd)
- Integration with existing workflow

## ✅ You're Done!

Your system now:
- ✅ Checks property availability
- ✅ Marks removed properties
- ✅ Filters them from map viewer
- ✅ Can permanently remove them

Run `python3 check_availability.py` now to get started!
