Real Estate Data Scraping in Python: Rightmove, Zillow, and Anti-Bot Bypass
Real Estate Data Scraping in Python: Rightmove, Zillow, and Anti-Bot Bypass
In today’s digital age, scraping real estate listings from platforms like Rightmove and Zillow has become a popular method for price research, market analysis, and even competitive intelligence. However, these platforms employ robust anti-bot technologies such as Cloudflare on Rightmove and PerimeterX on Zillow, making direct web scraping challenging without the right tools.
In this guide, we'll walk you through the practical steps to scrape real estate listings from Rightmove and Zillow using Python, focusing on how residential proxies can bypass these bot detection mechanisms. We'll use Python Playwright for handling JavaScript-rendered content and SQLite for storing the scraped data. This guide assumes you have a basic understanding of Python and web scraping principles.
Legal/ToS Disclaimer
Before we dive into the code, it’s important to note that scraping real estate listings from Rightmove and Zillow should be done in compliance with their terms of service (ToS). Both platforms prohibit automated data extraction unless explicitly allowed. Always check the platform's ToS before proceeding with any scraping activities.
For legitimate use cases such as price research and market analysis, you might find that using APIs provided by these platforms is a more ethical and reliable approach. However, if you need to scrape listings for personal or non-commercial purposes, residential proxies can help you stay under their radar while respecting the ToS.
Setting Up Your Environment
Before we start coding, ensure your Python environment is set up correctly. You'll need the following libraries:
pip install playwright sqlite3
To install Playwright and its dependencies, run:
playwright install
This will download the necessary browser binaries for Playwright to function.
Scraping Rightmove Listings with Python Playwright
Rightmove uses Cloudflare for bot detection. Residential proxies are essential here as they mimic real user behavior better than data center proxies. Bright Data and SmartProxy are examples of reliable residential proxy providers that can help you achieve this.
Here's a step-by-step guide to scrape Rightmove listings:
Step 1: Set Up Playwright with Proxies
First, we need to configure Playwright to use a residential proxy. Here’s how you can do it:
from playwright.sync_api import sync_playwright
def start_browser(proxy_url):
return sync_playwright().start().chromium.launch(
headless=False,
proxy={
"server": proxy_url,
},
)
def scrape_rightmove(browser, keyword):
context = browser.new_context()
page = context.new_page()
# Navigate to Rightmove search page
search_url = f"https://www.rightmove.co.uk/property-for-sale/find.html?searchType=SALE&locationIdentifier=POSTCODE%5E{keyword}&radius={0}&maxBedrooms=10&minBedrooms=1"
page.goto(search_url)
# Extract data
listings = []
for item in page.locator(".l-searchResult").all():
price = item.locator(".propertyCard-priceValue").text_content()
location = item.locator(".propertyCard-address").text_content()
beds_baths = item.locator(".propertyCard-features").text_content()
listings.append({"price": price, "location": location, "beds_baths": beds_baths})
context.close()
return listings
if __name__ == "__main__":
proxy_url = "http://username:[email protected]:port"
browser = start_browser(proxy_url)
keyword = "SW1A 0AA" # Example postcode
listings = scrape_rightmove(browser, keyword)
browser.close()
# Save to CSV or SQLite (example using SQLite)
import sqlite3
conn = sqlite3.connect('rightmove_listings.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS listings (price TEXT, location TEXT, beds_baths TEXT)''')
for listing in listings:
c.execute("INSERT INTO listings VALUES (?, ?, ?)", (listing["price"], listing["location"], listing["beds_baths"]))
conn.commit()
conn.close()
Step 2: Extracting and Storing Data
In the code above, we extract the price, location, and bed/bath information from each listing. The extracted data is then stored in a SQLite database.
Scraping Zillow Listings with Python Playwright
Zillow uses PerimeterX for bot detection. Again, residential proxies are essential here to bypass these measures.
Step 1: Set Up Playwright with Proxies
The setup process for Zillow is similar to Rightmove:
def scrape_zillow(browser, keyword):
context = browser.new_context()
page = context.new_page()
# Navigate to Zillow search page
search_url = f"https://www.zillow.com/homes/for_sale/{keyword}_rb/"
page.goto(search_url)
# Extract data
listings = []
for item in page.locator(".list-card").all():
price = item.locator(".list-card-price").text_content()
location = item.locator(".list-card-address").text_content()
beds_baths = item.locator(".list-card-info").nth(0).text_content()
listings.append({"price": price, "location": location, "beds_baths": beds_baths})
context.close()
return listings
Step 2: Extracting and Storing Data
The extraction process for Zillow is similar to Rightmove. Here’s how you can store the data:
# Save to CSV or SQLite (example using SQLite)
import sqlite3
conn = sqlite3.connect('zillow_listings.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS listings (price TEXT, location TEXT, beds_baths TEXT)''')
for listing in listings:
c.execute("INSERT INTO listings VALUES (?, ?, ?)", (listing["price"], listing["location"], listing["beds_baths"]))
conn.commit()
conn.close()
Handling Deduplication
To ensure that you don't store duplicate listings, you can deduplicate by listing ID. However, both Rightmove and Zillow do not provide a unique listing ID in their public-facing HTML. For this purpose, you might need to extract other fields and use them as a composite key.
Here’s an example of how you could handle deduplication:
def deduplicate_listings(listings):
seen = set()
deduplicated = []
for item in listings:
# Use location and price as a composite key for deduplication
key = (item["location"], item["price"])
if key not in seen:
seen.add(key)
deduplicated.append(item)
return deduplicated
# Example usage
listings = scrape_rightmove(browser, keyword)
deduplicated_listings = deduplicate_listings(listings)
Conclusion
Scraping real estate listings from Rightmove and Zillow requires careful handling of anti-bot technologies. Residential proxies are essential for bypassing these mechanisms. In this guide, we’ve shown how to use Python Playwright to scrape listings and store the data in SQLite databases.
Always ensure that your scraping activities comply with the platforms' ToS. For professional scraping needs, consider using reliable managed proxy services like Bright Data or SmartProxy.
If you'd rather not manage proxy lists manually, ProxyForge auto-tests and rotates proxies locally on your machine — one-off $29 unlock, no subscription: https://proxyforge.dev/#download
Free proxies break. ProxyForge doesn't.
The free lists above are public and often unreliable. ProxyForge auto-tests and rotates proxies on your machine, your IP — no stale lists, no shared pools, no surprises. One-off purchase, no subscription.
Download ProxyForge free →