GraphQL integrate, data correctness
This commit is contained in:
64
test_full_scraper.py
Normal file
64
test_full_scraper.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test the full scraper with one lot"""
|
||||
import asyncio
|
||||
import sys
|
||||
sys.path.insert(0, 'src')
|
||||
|
||||
from scraper import TroostwijkScraper
|
||||
|
||||
async def main():
|
||||
scraper = TroostwijkScraper()
|
||||
|
||||
from playwright.async_api import async_playwright
|
||||
|
||||
async with async_playwright() as p:
|
||||
browser = await p.chromium.launch(headless=True)
|
||||
page = await browser.new_page(
|
||||
viewport={'width': 1920, 'height': 1080},
|
||||
user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
||||
)
|
||||
|
||||
# Test with a known lot
|
||||
lot_url = "https://www.troostwijkauctions.com/l/%25282x%2529-duo-bureau-160x168-cm-A1-28505-5"
|
||||
|
||||
print(f"Testing with: {lot_url}\n")
|
||||
result = await scraper.crawl_page(page, lot_url)
|
||||
|
||||
if result:
|
||||
print(f"\n{'='*60}")
|
||||
print("FINAL RESULT:")
|
||||
print(f"{'='*60}")
|
||||
print(f"Lot ID: {result.get('lot_id')}")
|
||||
print(f"Title: {result.get('title', '')[:50]}...")
|
||||
print(f"Current Bid: {result.get('current_bid')}")
|
||||
print(f"Starting Bid: {result.get('starting_bid')}")
|
||||
print(f"Minimum Bid: {result.get('minimum_bid')}")
|
||||
print(f"Bid Count: {result.get('bid_count')}")
|
||||
print(f"Closing Time: {result.get('closing_time')}")
|
||||
print(f"Location: {result.get('location')}")
|
||||
|
||||
await browser.close()
|
||||
|
||||
# Verify database
|
||||
import sqlite3
|
||||
conn = sqlite3.connect('/mnt/okcomputer/output/cache.db')
|
||||
cursor = conn.execute("""
|
||||
SELECT current_bid, starting_bid, minimum_bid, bid_count, closing_time
|
||||
FROM lots
|
||||
WHERE lot_id = 'A1-28505-5'
|
||||
""")
|
||||
row = cursor.fetchone()
|
||||
conn.close()
|
||||
|
||||
if row:
|
||||
print(f"\n{'='*60}")
|
||||
print("DATABASE VERIFICATION:")
|
||||
print(f"{'='*60}")
|
||||
print(f"Current Bid: {row[0]}")
|
||||
print(f"Starting Bid: {row[1]}")
|
||||
print(f"Minimum Bid: {row[2]}")
|
||||
print(f"Bid Count: {row[3]}")
|
||||
print(f"Closing Time: {row[4]}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user