This project is a Scrapy-based web scraping application that extracts real estate listings from the sreality.cz API. The spider uses the public API endpoint (https://www.sreality.cz/api/cs/v2/estates) to fetch property data and stores it in a database.
The scraper extracts comprehensive property information including:
- Basic details: ID, name, category, type, locality
- Pricing: price, price_czk_value_raw, price_czk_unit, price_czk_alt_value_raw, price_czk_alt_unit
- Location: GPS coordinates (latitude/longitude), seo_locality
- Media: image links, floor plan availability
- Company information: embedded company details (URL, ID, name, logo)
- SEO metadata: category and type classifications
- Additional metadata: labels, exclusivity flags, new property indicators
- Python 3.6 or newer
- For database storage: MongoDB or PostgreSQL (optional - CSV export works without any database)
- Docker (optional, for database containerization)
To set up the project, follow these steps:
- Clone the repository to your local machine.
- Ensure you have Python installed.
- Install the required Python packages using the command:
pip install -r requirements.txt. - (Optional) Create a
.envfile in the project root if you want to customize output or use database pipelines:CSV_OUTPUT_DIR: Directory for CSV output (default:data)CSV_FILENAME: Custom CSV filename (default:sreality_<timestamp>.csv)MONGO_URI: MongoDB connection string (if using MongoDB pipeline)POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DB: PostgreSQL credentials (if using PostgreSQL pipeline)
- Optionally, you can use the provided
Dockerfileanddocker-compose.ymlfiles to set up a PostgreSQL container with Docker. To do this, run the command:docker-compose up -d.
To run the scraper:
- Navigate to the project directory.
- Run the spider using the command:
scrapy crawl sreality.
The spider will fetch sreality data from the API and export it to the configured output (CSV by default). The spider automatically paginates through all available listings.
The project includes three output pipelines:
- CSVPipeline (currently active): Exports data to
data/sreality_<timestamp>.csv. Configure output directory withCSV_OUTPUT_DIRand filename withCSV_FILENAMEenv vars - MongoDBPipeline: Stores data in MongoDB collection
srealityin databaserealestatecluster - PostgreSQLPipeline: Stores data in PostgreSQL table
sreality
To switch between pipelines, modify the ITEM_PIPELINES setting in sreality/settings.py.
Contributions are welcome. Please follow the standard fork and pull request workflow.
This project is distributed under the MIT License. See the LICENSE file for more details.
For any queries or further information, please contact the project maintainer at [me@karelmaly.com].