Skip to content

Commit d22b1f4

Browse files
authored
Merge pull request ed-donner#555 from ZnDream/clean-property-assistant-branch
Add AI Property Assistant contribution only
2 parents f8dca44 + 3691bf1 commit d22b1f4

File tree

2 files changed

+456
-0
lines changed

2 files changed

+456
-0
lines changed
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# AI Property Rental Assistant
2+
3+
A Python tool that scrapes UK property rental listings and uses OpenAI's GPT-4o-mini to provide personalized property recommendations based on your requirements.
4+
5+
## What It Does
6+
7+
- Scrapes property listings from OnTheMarket.com
8+
- Uses AI to analyze properties against your specific needs
9+
- Provides smart recommendations with reasons why properties match
10+
- Works for any UK location (currently configured for Durham)
11+
12+
## Quick Start
13+
14+
### Prerequisites
15+
- Python 3.7+
16+
- OpenAI API key ([Get one here](https://platform.openai.com/api-keys))
17+
18+
### Installation
19+
20+
1. **Install required packages:**
21+
```bash
22+
pip install requests beautifulsoup4 openai python-dotenv ipython
23+
```
24+
25+
2. **Set up your API key:**
26+
27+
Create a `.env` file in the same directory as your script:
28+
```
29+
OPENAI_API_KEY=your_openai_api_key_here
30+
```
31+
32+
3. **Run the script:**
33+
```bash
34+
python your_script_name.py
35+
```
36+
37+
## How to Use
38+
39+
### Basic Usage
40+
41+
The script is pre-configured to search for student housing in Durham. Just run it and you'll get AI-powered recommendations!
42+
43+
### Customizing Your Search
44+
45+
**Change the location:**
46+
```python
47+
website_url = "https://www.onthemarket.com/to-rent/property/manchester/"
48+
```
49+
50+
**Update your requirements:**
51+
```python
52+
user_needs = "I'm a young professional looking for a 1-bedroom flat in Manchester under £1,000/month"
53+
```
54+
55+
### Example Requirements You Can Use:
56+
- `"Student looking for shared accommodation under £600/month"`
57+
- `"Family needing 3-bedroom house with garden under £1,500/month"`
58+
- `"Professional couple wanting modern 2-bed apartment near city center"`
59+
60+
## Configuration
61+
62+
### Supported Cities
63+
Replace `durham` in the URL with any UK city:
64+
- `london` - London properties
65+
- `manchester` - Manchester properties
66+
- `birmingham` - Birmingham properties
67+
- `leeds` - Leeds properties
68+
- `bristol` - Bristol properties
69+
70+
### AI Behavior
71+
The system prompt is configured for UK rentals but you can modify it in the `system_prompt` variable to:
72+
- Focus on specific property types
73+
- Emphasize certain features (parking, garden, etc.)
74+
- Target different tenant types (students, families, professionals)
75+
76+
## Example Output
77+
78+
```
79+
Website Title: Properties to rent in Durham - OnTheMarket
80+
Content Length: 15847 characters
81+
82+
==================================================
83+
RENTAL RECOMMENDATIONS:
84+
==================================================
85+
86+
# Property Recommendations for Durham
87+
88+
Based on your requirements for a 2-bedroom student property under £2,000/month, here are my top recommendations:
89+
90+
## 1. **Student House on North Road** - £1,600/month
91+
- **Bedrooms:** 2
92+
- **Perfect because:** Well within budget, popular student area
93+
- **Features:** Close to university, furnished, bills included
94+
95+
## 2. **Modern Apartment City Centre** - £1,400/month
96+
- **Bedrooms:** 2
97+
- **Perfect because:** Great location, modern amenities
98+
- **Features:** Parking space, balcony, near shops
99+
```
100+
101+
## Requirements
102+
103+
Create a `requirements.txt` file:
104+
```
105+
requests>=2.28.0
106+
beautifulsoup4>=4.11.0
107+
openai>=1.0.0
108+
python-dotenv>=0.19.0
109+
ipython>=8.0.0
110+
```
111+
112+
Install with: `pip install -r requirements.txt`
113+
114+
## Important Notes
115+
116+
### API Costs
117+
- Uses GPT-4o-mini model (very affordable - ~$0.001 per request)
118+
- Monitor usage at: https://platform.openai.com/usage
119+
120+
### Rate Limits
121+
- Free OpenAI accounts: 3 requests per minute
122+
- The script makes 1 request per run
123+
124+
## How It Works
125+
126+
1. **Web Scraping:** Downloads the property listing page
127+
2. **Text Extraction:** Cleans HTML and extracts property information
128+
3. **AI Analysis:** Sends your requirements + property data to GPT-4
129+
4. **Smart Recommendations:** AI filters and ranks properties with explanations
130+
131+
## Troubleshooting
132+
133+
**"No API key found"**
134+
- Make sure `.env` file exists in the same folder as your script
135+
- Check the API key has no extra spaces
136+
- Verify it starts with `sk-proj-`
137+
138+
**"Error fetching website"**
139+
- Check your internet connection
140+
- Try a different city URL
141+
- Some websites may temporarily block requests
142+
143+
**No good recommendations**
144+
- Try adjusting your budget or requirements
145+
- Check if the website loaded properly (look at content length)
146+
- Try a different city with more properties
147+
148+
## Possible Improvements
149+
150+
- Make it interactive (ask for user input)
151+
- Support multiple property websites
152+
- Add price tracking over time
153+
- Include property images in analysis
154+
- Create a simple web interface
155+
156+
## Disclaimer
157+
158+
This tool is for educational purposes. Always verify property information directly with landlords or estate agents. Respect website terms of service.
159+
160+
---
161+
162+
**Need help?** Check that your `.env` file is set up correctly and you have an active internet connection. The script will tell you if there are any issues with your API key!

0 commit comments

Comments
 (0)