A Python scraper for extracting property listings from Pisos.com (Spanish real estate portal) using the ScrapingAnt API.
- 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
- Clone the repository:
git clone https://github.com/kami4ka/PisosScraper.git
cd PisosScraper- 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# 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| 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 Type | Description |
|---|---|
venta |
Buy |
alquiler |
Rent |
promociones |
New construction |
| 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 |
madrid_capital- Madrid citybarcelona_capital- Barcelona cityvalencia_capital- Valencia citysevilla_capital- Seville citymalaga_capital- Malaga citymadrid- Madrid regionbarcelona- Barcelona regionvalencia- Valencia region
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 |
This scraper uses the ScrapingAnt API for web scraping. You can provide the API key via:
- Environment variable:
export SCRAPINGANT_API_KEY=your_key - Command line:
--api-key YOUR_KEY
Configuration options in config.py:
SCRAPINGANT_API_KEY: Your API keyDEFAULT_MAX_WORKERS: Parallel request limit (default: 10)DEFAULT_TIMEOUT: Request timeout in seconds (default: 120)MAX_RETRIES: Number of retry attempts (default: 3)
MIT License