Skip to main content

ek-scraper

Simple scraper for kleinanzeigen.de searches with notifications for new ads.

Installation

Install this package from PyPi in a separate virtual environment using uv.

uv tool install ek-scraper

Usage

For the full usage check the ek-scraper --help command

Create a configuration file using

ek-scraper create-config <path/to/config.json>

The example configuration file will look like this:

{
  "filter": {
    "exclude_topads": true,
    "exclude_patterns": []
  },
  "notifications": {
    "pushover": {
        "token": "<your-app-api-token>",
        "user": "<your-user-api-token>",
        "device": []
    },
    "ntfy.sh": {
      "topic": "<your-private-topic>",
      "priority": 3
    },
    "email": {
      "smtp_host": "<smtp.example.com>",
      "smtp_port": "587",
      "username": "<your-account-username>",
      "password": "<your-account-password>",
      "sender": "<sender@example.com>",
      "recipient": ["<receiver@other.example.com>","<receiver@another.example.com>"],
      "bcc": ["<blindreceiver@third.example.com>","<blindreceiver@fourth.example.com>"]
    }
  },
  "searches": [
    {
      "name": "Wohnungen in Hamburg Altona",
      "url": "https://www.kleinanzeigen.de/s-wohnung-mieten/altona/c203l9497",
      "recursive": true
    }
  ]
}

See Configuration for details on all configuration options.

  • Configure one or more searches in the searches section of the configuration, see Searches for more details
  • Configure notifications in the notifications section of the configuration, see Notifications for details on notification configuration
  • (Optional) Configure filters in the filter section of the configuration, see Filter for more details

Run the following command to initialize the data store without sending any notifications:

ek-scraper run --no-notifications path/to/config.json

Afterwards, run

ek-scraper run path/to/config.json

to receive notifications according to your notifications configuration.

Development

Follow the steps below to set up a development environment for this project.

  1. Clone this repository

    git clone git@github.com:jonasehrlich/ek-scraper.git
    
  2. Change directory into the repository

    cd ek-scraper
    
  3. Create a virtual environment using uv

    uv sync
    
  4. (Optional) Install pre-commit environment using pre-commit or prek

Configuration

Searches

Searches can be configured in the searches array of the configuration file. Each of the searches can be configured with the following parameters.

Name Description
name Name of the search, use a descriptive one (required)
url URL of the first page of your search (required)
recursive Whether to follow all pages of the search result
(optional, defaults to true)

Filter

Filters can be configured in the filter section of the configuration file to exclude specific ads from your scrape results on the client side. The following settings can be configured.

Name Description
exclude_topads Whether to exclude top ads from the results (optional, defaults to true)
exclude_patterns Case-insensitive regular expression patterns used to exclude ads (optional)

Notifications

Notifications can be configured in the notifications section of the configuration file.

Push notifications using Pushover

Screenshot of a push notification using Pushover

ek-scraper supports push notifications to your devices using Pushover. For further information on the service check their terms and conditions.

The implementation for Pushover notifications will send a single notification per search, if new ads are discovered.

To configure Pushover for notifications from the scraper, first register at the service and create an application (e.g. ek-scraper). To use the service in ek-scraper, add the pushover object to the notifications object in your configuration file and fill the API tokens. Selection of the devices which will receive the notifications, is supported using the device array.

Name Description
token API token of the Pushover app (required)
user API token of the Pushover user (required)
device List of device names to send the notifications to
(optional, defaults to all devices)

Push notifications using ntfy.sh

Screenshot of a push notification using ntfy.sh

ek-scraper supports push notifications to your devices using ntfy.sh. For further information on the service check their terms and conditions.

The implementation for ntfy.sh notifications will send a single notification per search, if new ads are discovered.

To configure ntfy.sh for notifications from the scraper, define a topic and subscribe to it in the mobile app.

Note that topic names are public, so it's wise to choose something that cannot be guessed easily. This can be done by including a UUID, e.g. by running the following command in your shell:

echo "ek-scraper-$(uuidgen)"

To use the service in ek-scraper, add the ntfy.sh object to the notifications object in your configuration file and add the topic you previously subscribed to.

Name Description
topic Topic to publish the notifications to
priority Priority to send the notifications with (optional, defaults to 3)

Push notifications using E-Mail

ek-scraper supports push notifications to your devices using E-Mail.

The implementation for E-Mail notifications will send a single Email containing the new results per search, if new ads are discovered.

To configure E-Mail for notifications from the scraper, you need to add your smtp server details and credentials. To use the service in ek-scraper, add the email object to the notifications object in your configuration file. Currently only supporting STARTTLS.

Name Description
smtp_host SMTP host address (required)
smtp_port SMTP host port (default: 587) (required)
username Email account username (required)
password Email account password (required)
sender Outbound email address (required)
recipient Recipients who receive the email (optional)
bcc Recipients who the results get sent to as bcc (optional)

Running ek-scraper regularly

It should be avoided to run the tool too often to avoid getting your IP address blocked by kleinanzeigen.de

In order to run ek-scraper regularly on a Unix-like system, configure it as a cronjob.

To configure a cronjob, run

crontab -e

Edit the crontab table to run the command you want to run. A handy tool to check schedule configurations for cronjobs is crontab.guru.

For more information on configuring cronjobs use your favorite search engine.

Metadata

Release files for ek-scraper 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ek-scraper 0.4.0
File Size Uploaded Provenance Actions
ek_scraper-0.4.0.tar.gz 14.2 kB Without provenance Details for ek_scraper-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ek-scraper 0.4.0
File Interpreter ABI Platform Actions
ek_scraper-0.4.0-py3-none-any.whl Python 3 none any Details for ek_scraper-0.4.0-py3-none-any.whl

Total release size: 32.0 kB

Release files / ek_scraper-0.4.0.tar.gz

Download URL ek_scraper-0.4.0.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
932e6ecd96653c8f0455c77db88d8d96ec073307fb596655b8f39ddfbc1b3acd
BLAKE2b-256 checksum
How to use checksums
a37e7d164879ce426721e382fd47e8ccec8fbf2fc66526bfffe29fe293c3d2ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ek_scraper-0.4.0-py3-none-any.whl

Download URL ek_scraper-0.4.0-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55b1ec1a8a9692827b5459b1e526474f6e50b67ab0e2003edbf667234182d046
BLAKE2b-256 checksum
How to use checksums
f4ae1957f1cf6ef027583900fa3caac2f2e862e2519391e8820eb88eae667cde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ek-scraper 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page