54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Extract the GraphQL query being used"""
|
|
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()
|
|
|
|
graphql_requests = []
|
|
|
|
async def capture_request(request):
|
|
if 'graphql' in request.url:
|
|
graphql_requests.append({
|
|
'url': request.url,
|
|
'method': request.method,
|
|
'post_data': request.post_data,
|
|
'headers': dict(request.headers)
|
|
})
|
|
|
|
page.on('request', capture_request)
|
|
|
|
await page.goto("https://www.troostwijkauctions.com/l/%25282x%2529-duo-bureau-160x168-cm-A1-28505-5", wait_until='networkidle')
|
|
await asyncio.sleep(2)
|
|
|
|
print(f"Captured {len(graphql_requests)} GraphQL requests\n")
|
|
|
|
for i, req in enumerate(graphql_requests):
|
|
print(f"{'='*60}")
|
|
print(f"REQUEST #{i+1}")
|
|
print(f"{'='*60}")
|
|
print(f"URL: {req['url']}")
|
|
print(f"Method: {req['method']}")
|
|
|
|
if req['post_data']:
|
|
try:
|
|
data = json.loads(req['post_data'])
|
|
print(f"\nQuery Name: {data.get('operationName', 'N/A')}")
|
|
print(f"\nVariables:")
|
|
print(json.dumps(data.get('variables', {}), indent=2))
|
|
print(f"\nQuery:")
|
|
print(data.get('query', '')[:1000])
|
|
except:
|
|
print(f"\nPOST Data: {req['post_data'][:500]}")
|
|
|
|
print()
|
|
|
|
await browser.close()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|