Car Scraper Application
1. Scope A Python-based web application using Tailwind CSS for styling. The app allows users to search for car listings across five different websites (Carvana, Cars.com, AutoTrader, TrueCar, and CarMax) by leveraging the Browse.AI API.
2. Features • Search Button: Triggers the data-gathering robots. • Task Management: Tracks and waits for robots to complete tasks. • Data Display: Presents results in a user-friendly card layout with detailed car information.
3. Tech Stack • Backend: Python (Flask or FastAPI for API integration). • Frontend: Tailwind CSS for styling. • API Integration: Browse.AI for scraping and data retrieval o Documentation: https://www.browse.ai/docs/api/v2 o OpenAPI : https://api.browse.ai/v2/openapi • Deployment: Vercel, Vultr, or Digital Ocean.
4. User Flow Step 1: Initial Interface • A simple page with a search button and optional instructions. Step 2: Trigger Robot • User clicks "Search." • Backend triggers Browse.AI robots for. For simplicity, these robots will be pre-configured to a specific make, model, year, trim, and color, and each robot ID will be provided. o Carvana o Cars.com o AutoTrader o TrueCar o CarMax o Driveway • Browse.AI API key will be provided upon project approval. Step 3: Task Management • Retrieve taskID from the robot. • Poll Browse.AI API every 2–5 seconds to check the task status or utilize webhooks. Step 4: Fetch Results • Once a task is completed, retrieve results via Browse.AI API. • Aggregate and normalize data from all sources. Step 5: Display Results • Format the results in cards using Tailwind CSS. Each card includes: o Picture o Make o Model o Year o Trim o Color o Mileage o Price o Source o A button to view the car on the original website.
5. Key Components Frontend • Home Page: Search button and simple UI styled with Tailwind CSS. • Results Page: o A grid of cards displaying car details. o Tailwind CSS for responsive, modern design. Backend • API Routes: o /search (POST): Triggers robots and returns task IDs. o /results (GET): Polls task status and fetches results. • Utility Functions: o trigger_robot(robot_name): Makes API call to start the robot. o check_task_status(task_id): Polls Browse.AI for task status. o fetch_results(task_id): Retrieves and processes completed data.
6. API Integration • 1. Run a robot: o /POST: https://api.browse.ai/v2/robots/{robotId}/tasks o Headers: Include API Key as Bearer token. o Response: taskID = result.id o Docs: https://www.browse.ai/docs/api/v2#tag/tasks/operation/newRobotTask • 2. Determine task status: o 2a. Poll the task status: ▪ /GET: https://api.browse.ai/v2/robots/{robotId}/tasks/{taskId} ▪ Headers: Include API Key. ▪ Response: Task completion status. ▪ Docs: https://www.browse.ai/docs/api/v2#tag/tasks/operation/getRobotTask o 2b. (Alternate) Listen for Webhook “Task Finished” ▪ Docs: https://www.browse.ai/docs/api/v2#tag/webhooks/paths/taskWebhook/post • 3. Retrieve a task: o /GET: https://api.browse.ai/v2/robots/{robotId}/tasks/{taskId} o Headers: Include API Key. o Response: Scraped data. o Docs: https://www.browse.ai/docs/api/v2#tag/tasks/operation/getRobotTask
7. Tailwind CSS Components • Search Button: Large, centered button with hover effects. • Loader: Spinner to indicate task processing. • Cards: Responsive grid layout for displaying results with: o Image at the top. o Text sections for details. o A button with hover effect to view more.
8. Challenges & Solutions • Asynchronous Task Polling: Use Python's asyncio or Celery for efficient polling. • Data Normalization: Map diverse data structures from multiple robots to a unified format. • UI Consistency: Leverage Tailwind CSS utility classes for rapid and consistent styling.
9. Development Plan Phase 1: Setup • Create project structure (backend, frontend). • Configure Tailwind CSS and Browse.AI API. Phase 2: Backend • Build endpoints for triggering robots and fetching results. • Implement task polling logic or utilize webhooks. Phase 3: Frontend • Design the search page and results page. • Integrate Tailwind CSS components. Phase 4: Integration • Connect frontend to backend. • Test end-to-end functionality. Phase 5: Deployment • Deploy app to a shared GitHub repo. • Test on various devices for responsiveness.
Success story sharing