A Python FastAPI application that automates product purchases by analyzing unknown web page structures using web scraping and LLM analysis.
- Accepts product URLs and user tokens via API
- Scrapes product pages to identify purchase elements
- Uses LLM to analyze page structure and generate automation code
- Follows the purchase flow through multiple pages automatically
- Retrieves user payment information from MongoDB
- Completes purchases on behalf of users
app/
├── api/ # API endpoints
├── core/ # Core application settings
├── db/ # Database connections and queries
├── models/ # Pydantic models and MongoDB schemas
├── services/ # Business logic services
│ ├── scraper.py # Web scraping functionality
│ ├── llm.py # LLM integration for page analysis
│ └── automation.py # Purchase automation logic
└── utils/ # Utility functions
- Clone the repository
- Create a virtual environment:
python -m venv venv - Activate the virtual environment:
- Windows:
venv\Scripts\activate - Unix/MacOS:
source venv/bin/activate
- Windows:
- Install dependencies:
pip install -r requirements.txt - Copy
.env.exampleto.envand fill in your configuration - Run the application:
uvicorn app.main:app --reload
POST /api/purchase: Start an automated purchase process- Request body:
{ "product_url": "https://example.com/product/123", "user_token": "user_auth_token" }
- Request body:
- User submits a product URL and authentication token
- System scrapes the product page
- LLM analyzes the page structure to identify purchase elements
- System clicks the appropriate buttons (e.g., "Add to Cart")
- New page is scraped and analyzed
- Process repeats until purchase is complete
- User's payment information from MongoDB is used to complete the transaction
- Python 3.8+
- MongoDB
- OpenAI API key