Skip to content

Python scraper for Pisos.com Spanish real estate listings using ScrapingAnt API

Notifications You must be signed in to change notification settings

kami4ka/PisosScraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pisos.com Scraper

A Python scraper for extracting property listings from Pisos.com (Spanish real estate portal) using the ScrapingAnt API.

Features

  • Scrapes apartments, houses, chalets, studios, lofts, and more
  • Supports buy, rent, and new construction listings
  • Covers all Spanish regions and cities
  • Parallel scraping for improved performance
  • Extracts 35+ property attributes including price, area, rooms, location, amenities
  • Uses CSS selectors for reliable data extraction
  • Exports data to CSV format
  • Rate limiting and retry logic for reliability

Installation

  1. Clone the repository:
git clone https://github.com/kami4ka/PisosScraper.git
cd PisosScraper
  1. Create a virtual environment and install dependencies:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

Usage

Command Line

# Scrape apartments for sale in Madrid Capital
python main.py --contract venta --property pisos --location madrid_capital

# Scrape houses for rent in Barcelona
python main.py --contract alquiler --property casas --location barcelona_capital

# Scrape with page limit
python main.py --contract venta --property pisos --location valencia_capital --max-pages 5

# Scrape with property limit
python main.py --contract venta --property aticos --location sevilla --limit 100

# Enable verbose logging
python main.py --contract venta --property pisos --max-pages 3 -v

Available Options

Option Description
--contract, -c Contract type (default: venta)
--property, -p Property type (default: pisos)
--location, -l Location to search (default: madrid_capital)
--output, -o Output CSV file path (default: properties.csv)
--limit Maximum number of properties to scrape
--max-pages Maximum number of listing pages to scrape
--max-workers, -w Maximum parallel requests (default: 10)
--api-key, -k ScrapingAnt API key (overrides environment variable)
--verbose, -v Enable verbose logging

Contract Types

Contract Type Description
venta Buy
alquiler Rent
promociones New construction

Property Types

Property Type Description
pisos Apartments
casas Houses and chalets
aticos Penthouses
duplexs Duplexes
estudios Studios
lofts Lofts
fincas_rusticas Rural properties
locales Commercial premises
oficinas Offices
naves Warehouses
terrenos Land
garajes Garages
trasteros Storage rooms

Location Examples

  • madrid_capital - Madrid city
  • barcelona_capital - Barcelona city
  • valencia_capital - Valencia city
  • sevilla_capital - Seville city
  • malaga_capital - Malaga city
  • madrid - Madrid region
  • barcelona - Barcelona region
  • valencia - Valencia region

Output Format

The scraper exports data to CSV with the following fields:

Field Description
url Property listing URL
listing_id Unique listing identifier
title Property title
property_type Type (Piso, Casa, Atico, etc.)
contract_type Buy, rent, or new construction
price Listed price in EUR
price_per_sqm Price per square meter
city City name
district District name
neighborhood Neighborhood name
province Province name
living_area Living area in m²
useful_area Useful area in m²
rooms Number of rooms
bathrooms Number of bathrooms
floor Floor level
condition Property condition
age Property age
exterior Exterior type (Balcony, Terrace)
orientation Orientation (North, South, etc.)
community_fees Community fees
elevator Elevator availability
parking Parking availability
terrace Terrace availability
balcony Balcony availability
garden Garden availability
pool Swimming pool availability
air_conditioning AC availability
heating Heating availability
furnished Furnished status
storage Storage room availability
energy_rating Energy certificate class (A-G)
energy_consumption Energy consumption (kWh/m²/year)
emissions CO2 emissions (kg/m²/year)
description Property description
agency_name Real estate agency name
reference Agency reference number
updated_date Last update date
date_scraped Scraping timestamp

API Configuration

This scraper uses the ScrapingAnt API for web scraping. You can provide the API key via:

  1. Environment variable: export SCRAPINGANT_API_KEY=your_key
  2. Command line: --api-key YOUR_KEY

Configuration options in config.py:

  • SCRAPINGANT_API_KEY: Your API key
  • DEFAULT_MAX_WORKERS: Parallel request limit (default: 10)
  • DEFAULT_TIMEOUT: Request timeout in seconds (default: 120)
  • MAX_RETRIES: Number of retry attempts (default: 3)

License

MIT License

About

Python scraper for Pisos.com Spanish real estate listings using ScrapingAnt API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages