Spaces:
Sleeping
Sleeping
test(scrapers): Add reproduction script to isolate scraper output
Browse files- tests/debug_scrapers.py +63 -0
tests/debug_scrapers.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import logging
|
| 3 |
+
import json
|
| 4 |
+
import sys
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
# Ensure the project root is in the python path
|
| 8 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 9 |
+
|
| 10 |
+
from booking_scraper import BookingScraper
|
| 11 |
+
from airbnb_scraper import AirbnbScraper
|
| 12 |
+
|
| 13 |
+
# Configure logging
|
| 14 |
+
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
| 15 |
+
|
| 16 |
+
async def debug_booking():
|
| 17 |
+
print("\n--- Debugging Booking.com Scraper ---")
|
| 18 |
+
scraper = BookingScraper()
|
| 19 |
+
try:
|
| 20 |
+
# Search parameters
|
| 21 |
+
city = "Amsterdam"
|
| 22 |
+
checkin = "2026-03-01"
|
| 23 |
+
checkout = "2026-03-08"
|
| 24 |
+
adults = 4
|
| 25 |
+
|
| 26 |
+
print(f"Searching {city} for {adults} adults from {checkin} to {checkout}...")
|
| 27 |
+
results = await scraper.search_booking(city, checkin, checkout, adults)
|
| 28 |
+
|
| 29 |
+
print(f"Found {len(results)} results.")
|
| 30 |
+
for i, deal in enumerate(results[:3]):
|
| 31 |
+
print(f"\nResult #{i+1}:")
|
| 32 |
+
print(json.dumps(deal, indent=2))
|
| 33 |
+
|
| 34 |
+
except Exception as e:
|
| 35 |
+
print(f"Error debugging Booking.com: {e}")
|
| 36 |
+
|
| 37 |
+
async def debug_airbnb():
|
| 38 |
+
print("\n--- Debugging Airbnb Scraper ---")
|
| 39 |
+
scraper = AirbnbScraper()
|
| 40 |
+
try:
|
| 41 |
+
# Search parameters
|
| 42 |
+
region = "Amsterdam"
|
| 43 |
+
checkin = "2026-03-01"
|
| 44 |
+
checkout = "2026-03-08"
|
| 45 |
+
adults = 4
|
| 46 |
+
|
| 47 |
+
print(f"Searching {region} for {adults} adults from {checkin} to {checkout}...")
|
| 48 |
+
results = await scraper.search_airbnb(region, checkin, checkout, adults)
|
| 49 |
+
|
| 50 |
+
print(f"Found {len(results)} results.")
|
| 51 |
+
for i, deal in enumerate(results[:3]):
|
| 52 |
+
print(f"\nResult #{i+1}:")
|
| 53 |
+
print(json.dumps(deal, indent=2))
|
| 54 |
+
|
| 55 |
+
except Exception as e:
|
| 56 |
+
print(f"Error debugging Airbnb: {e}")
|
| 57 |
+
|
| 58 |
+
async def main():
|
| 59 |
+
await debug_booking()
|
| 60 |
+
await debug_airbnb()
|
| 61 |
+
|
| 62 |
+
if __name__ == "__main__":
|
| 63 |
+
asyncio.run(main())
|