# Complete Guide: How to Scrape Pisos.com Listings Using Python

This guide demonstrates how to extract Spanish property listings from [pisos.com](http://pisos.com) using Python: homes for sale or for rent, filtered by municipal location, price boundaries, property type, and bedroom count, delivered as structured dataset rows. The extraction tool is [**Pisos.com**](http://Pisos.com) **Scraper** (`reventadata/pisos-scraper`), an Apify Actor that you drive programmatically using the official Apify client library for Python.

By following this tutorial, you will understand the configuration options the Actor accepts, how search filters are validated before execution, what fields each dataset row contains, where the platform limits lie, and how to automate periodic market monitoring on a schedule. Whether you are conducting regional valuation studies, aggregating agency portfolios, or setting up automated alerts for newly listed properties, you can obtain reliable data without building custom parsers from scratch. The prerequisites are minimal: Python 3.11 or newer, a free Apify account, and an API token. Every sample record shown in this guide comes from a real platform run of Madrid listings, parsed with the Actor's production extraction logic.

---

## TL;DR

In this tutorial you will learn to run `reventadata/pisos-scraper` from Python using `apify-client`, pass targeted search filters (`operation`, `propertyType`, `location`, `minPrice`, `maxPrice`, `minRooms`, `minSurfaceM2`, and `sortBy`), and receive clean dataset rows containing property title, asking price, municipality, surface area, bedrooms, bathrooms, floor level, advertiser phone numbers, and agency links. You will also learn about the optional `fetchDetails` flag for full property descriptions and energy performance certificates, the 3,000-result pagination ceiling [pisos.com](http://pisos.com) enforces per query, and how to repeat searches on automated schedules. The tool is available on the [Pisos.com Scraper page on Apify Store](https://apify.com/reventadata/pisos-scraper).

---

## Prerequisites and setup

To follow this tutorial, you need an active Apify account, a working Python 3.11+ environment, and your personal API token. Free Apify accounts can be created within seconds using either an email address or a GitHub account. Apify Console is the cloud web interface where you monitor your Actors, inspect runs, and download datasets. You can find your API token under **Settings > API & Integrations** in the Console.

Install the Apify client library in your local environment and export your API token as an environment variable so your scripts can access it securely:

```bash
pip install -U "apify-client~=3.0"
export APIFY_API_TOKEN="your_apify_token_here"
```

The [Apify API client for Python documentation](https://docs.apify.com/api/client/python/) details the full capabilities of the client library. No local headless browsers, scraping frameworks, or proxy pools are needed on your machine.

---

## Understanding [Pisos.com](http://Pisos.com) Scraper

[Pisos.com](http://Pisos.com) Scraper mirrors the search functionality available on the public [pisos.com](http://pisos.com) web portal. It supports both property sales (`sale`) and long-term rental searches (`rent`) across Spanish municipalities and provinces. The scraper handles three primary property types: flats (`pisos`), houses (`casas`), and penthouses (`aticos`).

Each listing row contains attributes extracted from search cards, including listing URL, price, price text, currency, living area in square metres, bedroom and bathroom numbers, floor level, location text, municipality, province, geographical coordinates, agency profile URLs, and advertiser telephone numbers when published. When the `fetchDetails` input flag is enabled, the Actor opens each property's dedicated page to gather full description texts, last updated dates, reference numbers, structured feature lists, energy efficiency classifications, and the agency's registered street address.

Understanding the site's structural boundaries is essential for data collection planning. [pisos.com](http://pisos.com) enforces a strict ceiling of 100 pages per query (30 listings per page, or 3,000 listings maximum; pages beyond 100 are not served). When market scans exceed 3,000 listings, you partition your queries across price ranges or narrower geographical place slugs.

---

## Step-by-step walkthrough

### Step 1: Open the Actor in Apify Console

Navigate to the [Pisos.com Scraper page on Apify Store](https://apify.com/reventadata/pisos-scraper). Clicking the **Try for free** button opens the Actor's execution interface in the Apify Console. When interacting through Python, you only need the Actor slug: `reventadata/pisos-scraper`.

### Step 2: Configure search parameters

The Actor receives a JSON object that controls which search query is executed on [pisos.com](http://pisos.com):

- `operation`: Select `sale` (queries `/venta/`) or `rent` (queries `/alquiler/`). Values outside these enums are refused before the run starts.
- `propertyType`: Choose from `pisos`, `casas`, or `aticos`.
- `location`: The exact geographical place slug used by [pisos.com](http://pisos.com) (e.g., `madrid`, `barcelona`, `vizcaya_bizkaia`). In the search URL `https://www.pisos.com/venta/pisos-madrid/`, the location slug is `madrid`. Entering an invalid slug causes the portal to report that the place does not exist, ending the run with an explanatory error.
- `minPrice` and `maxPrice`: Numeric limits in EUR (or monthly rent).
- `minRooms`: Minimum number of bedrooms (1 to 6).
- `minSurfaceM2`: Minimum living surface area in square metres.
- `hasTerrace`: Boolean switch to restrict results to properties with terraces.
- `sortBy`: Sorting criteria (`relevance`, `newest`, `priceAsc`, `priceDesc`, `roomsDesc`, `roomsAsc`, `areaDesc`, `areaAsc`).
- `maxItems`: Safety limit on the number of listings stored.
- `maxPages`: Upper limit on search result pages crawled.
- `fetchDetails`: Boolean flag to enable deep extraction of listing detail pages.

A typical configuration for querying Madrid apartments looks like this:

```json
{
    "operation": "sale",
    "propertyType": "pisos",
    "location": "madrid",
    "minPrice": 100000,
    "maxPrice": 500000,
    "minRooms": 2,
    "minSurfaceM2": 60,
    "sortBy": "priceAsc",
    "maxItems": 30,
    "maxPages": 1
}
```

---

## Working with the API

You can execute searches directly from your Python code using the official `apify-client` library. The script passes your search dictionary to `client.actor("reventadata/pisos-scraper").call()`, blocks until the run completes, checks the execution status, and retrieves the dataset records:

```python
import os
from apify_client import ApifyClient

# 1. Initialise the client with your token from the environment
client = ApifyClient(os.environ["APIFY_API_TOKEN"])

# 2. Describe the search: flats for sale in Madrid
run_input = {
    "operation": "sale",
    "propertyType": "pisos",
    "location": "madrid",
    "maxItems": 10,
    "maxPages": 2,
}

# 3. Start the Actor and wait for it to finish
run = client.actor("reventadata/pisos-scraper").call(run_input=run_input)
if run is None or run.status != "SUCCEEDED":
    status = run.status if run else "unknown"
    raise SystemExit(f"Run did not succeed (status: {status}).")

# 4. Read the rows from the run's default dataset
items = client.dataset(run.default_dataset_id).list_items().items
print(f"Retrieved {len(items)} listings.\n")

# 5. Print a summary per listing, including price per square metre
for item in items:
    title = item.get("title")
    price = item.get("price")
    area = item.get("areaM2")
    rooms = item.get("rooms")
    baths = item.get("bathrooms")
    municipality = item.get("municipality")
    phone = item.get("phone") or "no phone published"
    per_m2 = f"{price / area:.1f} EUR/m2" if price and area else "no surface"
    print(f"{title} | {municipality} | {price} EUR | {area} m2 | {per_m2}")
    print(f"  Bedrooms: {rooms}, Bathrooms: {baths}, Phone: {phone}")
```

Running this script fetches the default dataset and prints extracted summary metrics for each property listing:

```text
Piso en calle de San Cándido | Madrid Capital | 439900 EUR | 90 m2 | 4887.8 EUR/m2
  Bedrooms: 3, Bathrooms: 2, Phone: 919383603
Piso en calle San Cristóbal | San Martín de la Vega | 181000 EUR | 103 m2 | 1757.3 EUR/m2
  Bedrooms: 2, Bathrooms: 2, Phone: 919388791
Piso en calle de Pont de Molins | Madrid Capital | 252000 EUR | 69 m2 | 3652.2 EUR/m2
  Bedrooms: 3, Bathrooms: 1, Phone: 919388797
```

---

## Advanced usage patterns

For enterprise monitoring pipelines or comprehensive market studies, you can combine several input strategies to extract maximum value:

1. **Systematic price banding:** Because [pisos.com](http://pisos.com) enforces a 3,000-item ceiling per search URL, broad queries across large metropolitan areas like Madrid or Barcelona easily exceed 100 pages. To retrieve all listings without hitting the ceiling, partition your queries into discrete price bands using `minPrice` and `maxPrice` (for example, 100,000 to 150,000 EUR, then 150,000 to 200,000 EUR). This approach lets you gather full datasets while staying within per-query boundaries.
2. **Targeted geographical decomposition:** Instead of querying an entire province under a single slug like `madrid`, pass specific municipal slugs (such as `madrid_capital_zona_urbana`, `bilbao`, or `barcelona`) to keep query sizes well within the pagination ceiling and organize your database by geographical administrative zone.
3. **Automated difference tracking:** Run the Actor on a daily schedule with `sortBy: "newest"` and a modest `maxPages` cap (such as 2 to 5 pages). Store the output in a relational database or search index and compare newly observed `adId` values against previous runs to detect newly listed properties or price reductions immediately.
4. **Selective detail enrichment:** Keep `fetchDetails: false` during routine broad sweeps, and trigger a targeted detail pass only on listings that meet strict investment criteria (such as high price-per-square-metre bargains).

---

## Understanding your data

The resulting dataset provides a consistent structure across every run. Every row contains standard card attributes, and all detail columns are present (populated with `null` when `fetchDetails` is not used), ensuring schema stability downstream.

Here is a verified listing row extracted during the Madrid run:

```json
{
  "id": "65077851154.510936",
  "adId": "65077851154",
  "advertiserId": "510936",
  "url": "https://www.pisos.com/comprar/piso-carabanchel_san_isidro28019-65077851154_510936/",
  "operation": "sale",
  "propertyType": "piso",
  "title": "Piso en calle de San Cándido",
  "locationText": "San Isidro (Distrito Carabanchel. Madrid Capital)",
  "municipality": "Madrid Capital",
  "province": "Madrid",
  "latitude": 40.399459,
  "longitude": -3.7209612,
  "price": 439900,
  "priceText": "439.900 €",
  "currency": "EUR",
  "rooms": 3,
  "bathrooms": 2,
  "areaM2": 90,
  "floor": "1ª planta",
  "otherCharacteristics": null,
  "descriptionSnippet": "Hay zonas de madrid donde se compra una vivienda. Y hay zonas donde se compra calidad de vida.\n\nEstudio pradera de san isidro, s.l...",
  "badges": [
    "TOP",
    "Oportunidad"
  ],
  "photoCount": 33,
  "imageUrl": "https://fotos.imghs.net/mm-wp/510936/65077851154.510936/510936_65077851154_74e3db83-c061-48be-afcc-7ca46520b75f.jpg",
  "isNewDevelopment": false,
  "phone": "919383603",
  "agencyProfileUrl": "https://www.pisos.com/inmobiliaria-redpiso_estudio_pradera_de_san_isidro/",
  "agencySlug": "redpiso_estudio_pradera_de_san_isidro",
  "detailFullDescription": null,
  "detailLastUpdated": null,
  "detailReference": null,
  "detailFeatures": null,
  "detailEnergyClass": null,
  "detailEnergyConsumption": null,
  "detailEnergyEmissions": null,
  "agencyName": null,
  "agencyAddress": null,
  "searchUrl": "https://www.pisos.com/venta/pisos-madrid/",
  "page": 1,
  "scrapedAt": "2026-11-15T21:03:45+00:00"
}
```

Key fields to note:

- `price`: Clean integer value representing the total sale price or monthly rental amount.
- `areaM2`: Parsed integer representing usable area. Missing or unspecified surface areas return `null`.
- `phone`: Published telephone number from the search card, or `null` when the card displays none.
- `agencySlug`: Identifies real estate agencies for portfolio aggregation.

---

## Troubleshooting guide

- **Empty dataset with status SUCCEEDED:** The run executed normally, but no listings matched your filter combinations (for example, combining high bedroom counts with low maximum price thresholds). Check your query directly on [pisos.com](http://pisos.com) to confirm that matching properties exist under those specific criteria.
- **Run aborts with status FAILED:** An invalid `location` slug was provided. The site does not recognise the location slug, causing the Actor to fail immediately with an informative message. Always copy place slugs from active search URLs on [pisos.com](http://pisos.com) rather than guessing names.
- **Discrepancies in total expected listings:** Broad search queries displaying tens of thousands of listings on [pisos.com](http://pisos.com) cannot be scraped in a single run due to the 3,000-item portal limit. Split large queries across multiple narrower runs using price intervals or smaller municipalities.
- **Missing contact telephone numbers:** The `phone` field is `null` when a listing card does not display a telephone number.

---

## Best practices

- **Start with small page caps:** When testing new configurations, set `maxPages: 1` and `maxItems: 10` to verify data shapes and filter accuracy before running large extraction batches.
- **Enable** `fetchDetails` **judiciously:** Card extraction reads listings in batches of 30. Setting `fetchDetails: true` visits each listing page individually, taking longer to finish. Use it only when full descriptions, energy ratings, or physical addresses are necessary.
- **Validate place slugs:** Verify that your `location` slug matches the path structure of [pisos.com](http://pisos.com) to avoid unnecessary input failures.
- **Respect portal limits:** Keep your crawls focused on specific areas and price bands rather than launching massive unfiltered crawls that hit the 3,000-item ceiling.

---

## Conclusion and next steps

For current pricing and details, see the [Store page](https://apify.com/reventadata/pisos-scraper).

Automating your real estate data pipeline is straightforward. You can configure scheduled executions via the [Apify Schedules platform](https://docs.apify.com/platform/schedules), retrieve data in CSV, JSON, or Excel via the [Apify Dataset API](https://docs.apify.com/platform/storage/dataset), or trigger downstream processing pipelines through [Apify Webhooks](https://docs.apify.com/platform/integrations/webhooks/actions).

---

## Resources

- [Pisos.com Scraper on Apify Store](https://apify.com/reventadata/pisos-scraper)
- [Apify Python Client Documentation](https://docs.apify.com/api/client/python/)
- [Apify Schedules Documentation](https://docs.apify.com/platform/schedules)
- [Apify Webhooks Documentation](https://docs.apify.com/platform/integrations/webhooks/actions)

*About the author: reventadata builds and publishes data extraction Actors on the Apify Store.*
