By the end of this tutorial you will have a working Python script that pulls Spanish real estate listings from pisos.com into structured dataset rows: sale or rental price, address, municipality, surface area, bedrooms, bathrooms, floor level, advertiser phone, and agency profile links.
Pisos.com is a Spanish property portal listing homes across Spain. Pisos.com Scraper (reventadata/pisos-scraper) is the Apify Actor built for this site to extract its listings. You describe your search parameters, and it returns one clean row per listing.
This guide runs the Actor from Python using the official Apify client library. Every sample row shown below comes from a live capture of Madrid property listings, not an invented dataset. ⏱️ This walkthrough takes about 10 minutes to complete.
Prerequisites
You need three basic things:
- Python 3.11 or newer installed on your system.
- A free Apify account, which you can create using an email address or a GitHub login.
- Your personal Apify API token, located under Settings > API & Integrations in the Apify Console.
Install the Apify client package and set your token in your environment:
pip install -U "apify-client~=3.0"
export APIFY_API_TOKEN="your_apify_token_here"
No browser automation setup or local crawler maintenance is required. The Actor runs in the cloud.
What you'll achieve
You will search pisos.com for properties for sale in Madrid, execute the search using Python, and read the resulting dataset rows into memory. Your script will calculate a price per square metre for each listing and print a summary showing the property title, location, asking price, living area, and advertiser phone number.
The same approach applies to rental listings, country houses, penthouses, or different Spanish provinces. You only need to adjust the input configuration parameters. Whether you are building an automated property market dashboard, monitoring neighborhood price fluctuations, or aggregating agency contacts, this setup gives you clean structured data without maintaining custom web parsers.
Step 1: Open Pisos.com Scraper
Open the Pisos.com Scraper page on Apify Store. The Try for free button there opens the Actor in Apify Console. Because this tutorial uses Python and the Apify API client, you only need the Actor's unique identifier, reventadata/pisos-scraper.
Step 2: Choose your search parameters
The search is configured using several input fields matching the site's search filters:
-
operation:salefor purchases orrentfor long-term rentals. Any other value is refused before the run starts. -
propertyType:pisos(flats),casas(houses), oraticos(penthouses). Any invalid type is refused before the run starts. -
location: The pisos.com place slug, such asmadrid,barcelona, orvizcaya_bizkaia. This corresponds to the slug in the site's search URL. An unknown slug causes the site to report that the place does not exist, ending the run with an error. -
minPriceandmaxPrice: Price boundaries in EUR (or monthly rent for rentals). -
minRooms: Minimum number of bedrooms (1 to 6, where 6 means 6 or more). -
minSurfaceM2: Minimum surface area in square metres. -
hasTerrace: Boolean switch to keep only listings tagged with a terrace. -
sortBy: Sorting order (relevance,newest,priceAsc,priceDesc,roomsDesc,roomsAsc,areaDesc,areaAsc). -
maxItems: Total number of listings to collect (default is 100). -
maxPages: Maximum number of search result pages to crawl (each page holds up to 30 listings). -
fetchDetails: Optional boolean switch to open each listing page for detailed descriptions and energy certificates.
An example search configuration for Madrid flats looks like this:
{
"operation": "sale",
"propertyType": "pisos",
"location": "madrid",
"minPrice": 100000,
"maxPrice": 500000,
"minRooms": 2,
"minSurfaceM2": 60,
"sortBy": "priceAsc",
"maxItems": 30,
"maxPages": 1
}
Step 3: Run it from Python
The following script initializes the Apify client, starts a run for Madrid properties, waits for completion, and processes each listing:
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}")
Step 4: Read the output
When the script runs against the live Actor, it prints the extracted property summary lines. For example, running this input against Madrid listings produced the following records:
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
Each listing provides exact numerical fields for price, square metres, rooms, and contact phone numbers where available.
Step 5: Add detailed features and descriptions (optional)
By default, the Actor collects the data visible on search cards without visiting individual detail pages. If you set fetchDetails to true, the Actor visits each property page to retrieve additional fields: full description text, last update date, agency reference ID, feature list, energy certificate classification, consumption, emissions, and agency street address.
Visiting detail pages takes longer to execute, so keep this option disabled if card-level data meets your requirements.
Understanding your results
Each dataset row contains structured attributes describing the listing, its physical characteristics, geographical location, and agency details:
-
id,adId,advertiserId: Unique identifiers assigned to the advertisement and advertiser. -
url: Direct canonical URL to the listing page on pisos.com. -
operation,propertyType: Operation (saleorrent) and property category (piso,casa,atico). -
title,descriptionSnippet: Title line and preview text from the search card. -
price,priceText,currency: Asking price as an integer, original formatted text, and currency code (EUR). -
rooms,bathrooms,areaM2,floor: Room count, bathroom count, usable surface in square metres, and floor level. -
locationText,municipality,province,latitude,longitude: Location description, municipality name, province name, and geographic coordinates. -
phone: Direct contact telephone number published on the card (null if the advertiser did not display one). -
agencyProfileUrl,agencySlug: Link to the advertiser's agency directory profile on pisos.com. -
photoCount,imageUrl: Total count of photos and link to the main listing image. -
detailFullDescription,detailLastUpdated,detailReference,detailFeatures,detailEnergyClass,detailEnergyConsumption,detailEnergyEmissions,agencyName,agencyAddress: Detailed fields populated whenfetchDetailsis enabled; otherwise null.
Here is a complete row captured from the Madrid run:
{
"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"
}
Pro tips
-
Observe the 3,000-listing ceiling. pisos.com displays at most 100 pages of 30 listings (3,000 total) for any given query; pages beyond 100 are not served. When a broad search exceeds this limit, divide the search into smaller slices using price bands (
minPriceandmaxPrice) or specific municipal slugs. -
Sort by newest for monitoring. Setting
sortBytonewestorders listings by publication date, allowing periodic cron jobs to check only the first page or two for freshly listed homes. -
Filter by property type. The portal defaults to returning standard flats (
pisos). If you are targeting houses or penthouses, setpropertyTypetocasasoraticos. - Compute custom ratios downstream. The dataset provides raw numeric values for price and surface area. You can compute custom valuation metrics such as price per square metre or price per bedroom directly in Python.
-
Use
fetchDetailsonly when necessary. Visiting individual listing pages takes additional time. If you only require card-level data such as price, rooms, and coordinates, keeping it off optimizes execution speed.
Troubleshooting
- Zero rows returned with status SUCCEEDED. The search query was valid, but no matching properties met the specified criteria. Check your price or bedroom filters on pisos.com directly to confirm availability.
-
Run finished with status FAILED. If the site cannot find the specified
locationslug, the run terminates immediately with an error explaining that the place slug does not exist. Verify the slug against a live search URL on pisos.com. -
Empty phone field on certain rows. When no telephone is displayed on a listing's search card, the Actor sets
phonetonull.
Next steps
For current pricing and details, see the Store page.
To automate property tracking, set up an Apify Schedule to run the Actor automatically every morning. You can export datasets to JSON, CSV, or Excel formats using the Apify Dataset API, or configure an Apify Webhook to alert your application when a scrape finishes.
About the author: reventadata builds and publishes data extraction Actors on the Apify Store.
Top comments (0)