#!/usr/bin/env python3 """Find the API endpoint by monitoring network requests""" import asyncio import json from playwright.async_api import async_playwright async def main(): async with async_playwright() as p: browser = await p.chromium.launch(headless=True) page = await browser.new_page() requests = [] responses = [] async def log_request(request): if any(term in request.url for term in ['api', 'graphql', 'lot', 'auction', 'bid']): requests.append({ 'url': request.url, 'method': request.method, 'headers': dict(request.headers), 'post_data': request.post_data }) async def log_response(response): if any(term in response.url for term in ['api', 'graphql', 'lot', 'auction', 'bid']): try: body = await response.text() responses.append({ 'url': response.url, 'status': response.status, 'body': body[:1000] }) except: pass page.on('request', log_request) page.on('response', log_response) print("Loading lot page...") await page.goto("https://www.troostwijkauctions.com/l/woonunit-type-tp-4-b-6m-nr-102-A1-37889-102", wait_until='networkidle') # Wait for dynamic content await asyncio.sleep(3) print(f"\nFound {len(requests)} relevant requests") print(f"Found {len(responses)} relevant responses\n") for req in requests[:10]: print(f"REQUEST: {req['method']} {req['url']}") if req['post_data']: print(f" POST DATA: {req['post_data'][:200]}") print("\n" + "="*60 + "\n") for resp in responses[:10]: print(f"RESPONSE: {resp['url']}") print(f" Status: {resp['status']}") print(f" Body: {resp['body'][:300]}") print() await browser.close() if __name__ == "__main__": asyncio.run(main())