DEV Community

Cover image for How to Scrape DBA Denmark Listings in Python with DBA Scraper
ReventaData
ReventaData

Posted on Originally published at apify.com

How to Scrape DBA Denmark Listings in Python with DBA Scraper

By the end of this tutorial you will have a Python script that extracts second-hand listings from dba.dk into clean, structured records: title, asking price in Danish kroner, locality, coordinates, seller classification, shipping status and photo links.

DBA (Den Blå Avis) is Denmark's primary second-hand marketplace. DBA Scraper (reventadata/dba-scraper) is the Apify Actor built to search its marketplace and return each matching ad as a structured dataset row. You provide a keyword query, and the Actor handles data extraction directly.

This guide runs the Actor from Python using the official Apify API client. Every sample row and metric in this walkthrough comes from an authentic platform run of an iPhone search on DBA, capturing 10 clean records in 4.616 seconds without fabricated data or simulated responses.


Prerequisites

You need three basic prerequisites to get started:

  1. Python 3.11 or newer installed on your system.
  2. A free Apify account, created with your email address or GitHub credentials.
  3. Your personal API token, located under Settings > API & Integrations in the Apify Console.

Install the official client library and configure your API token in your terminal environment:

pip install -U "apify-client~=3.0"
export APIFY_API_TOKEN="your_apify_token_here"
Enter fullscreen mode Exit fullscreen mode

No local browser installation or browser automation tooling is required. The Actor runs entirely on Apify infrastructure.


What you'll achieve

In this tutorial, you will search DBA for iPhone listings, execute the Actor programmatically from Python, and parse the resulting dataset records. You will output a formatted summary for each listing displaying its title, asking price, location, seller type, and whether delivery is offered.

DBA listings range from small private sales to professional electronics shops. You will see how the Actor normalizes asking prices, tags whether instant purchase is enabled, and surfaces seller classifications.

The same workflow functions whether you are monitoring second-hand smartphone deals, analyzing regional price variations across Denmark, or gathering catalog data for market research. Adjusting the target items requires modifying only the input dictionary passed to the Actor.


Step 1: Open DBA Scraper

Navigate to the DBA Scraper page on Apify Store. Clicking Try for free opens the Actor interface inside Apify Console, where you can view input fields and test searches interactively. For automation via Python, you only need the Actor's technical identifier: reventadata/dba-scraper.


Step 2: Choose your search parameters

The Actor configuration accepts several input parameters defined in its schema:

  • searchQueries: A list of search terms or keywords (for example ["iphone"]). This parameter is mandatory.
  • minPrice and maxPrice: Optional integer boundaries in DKK. These limits are sent directly to DBA's search engine, which filters results before returning listings. If minPrice exceeds maxPrice, the Actor raises an input validation error.
  • maxItems: An integer cap on the total number of items saved across all queries. The default is 100.
  • maxPages: An integer cap on pagination pages per query. DBA limits search pagination to a ceiling of 50 pages (roughly 2,650 items).
  • shippingOnly: A boolean flag. When set to true, the Actor keeps only listings that offer package delivery.
  • requireKeywordMatch: A boolean flag enabled by default. It confirms that the query terms appear in the listing's title or brand before storing the row, using Danish letter folding for characters like ø and æ.

A typical configuration searching for iPhones looks like this:

{
    "searchQueries": ["iphone"],
    "maxItems": 10,
    "maxPages": 1
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Run it from Python

The following Python script initializes the Apify client, executes the Actor with your configured input, waits for completion, and prints a structured summary from the default dataset:

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: iPhone listings on DBA
run_input = {
    "searchQueries": ["iphone"],
    "maxItems": 10,
    "maxPages": 1,
}

# 3. Start the Actor and wait for it to finish
run = client.actor("reventadata/dba-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 two lines per listing: title, price, location, seller type and shipping
for item in items:
    price = item.get("price")
    currency = item.get("currency")
    price_str = f"{price} {currency}" if price is not None else "no price stated"
    shipping = "shipping offered" if item.get("shippingAvailable") else "pickup only"
    print(f"{item.get('title')} | {price_str} | {item.get('location')}")
    print(f"  seller: {item.get('sellerType')}, {shipping}, brand: {item.get('brand')}")
Enter fullscreen mode Exit fullscreen mode

The script verifies that run.status equals SUCCEEDED before fetching dataset items. In the Apify Python SDK 3.x, call() returns a typed run object with direct attribute access.


Step 4: Inspect the output

Executing the script against DBA produces a concise output block for each extracted listing. On our sample run of 10 items, the first three listings printed the following lines:

Iphone x pro max, iphone x, iphone 6, iphone 5 | 200 DKK | Brøndby Strand
  seller: private, pickup only, brand: Apple
Iphone 16 Pro | 4650 DKK | Dragør
  seller: private, pickup only, brand: Apple
Apple iPhone 15 128 GB | 2800 DKK | Charlottenlund
  seller: private, shipping offered, brand: Apple
Enter fullscreen mode Exit fullscreen mode

Notice that two listings require local pickup while the third supports shipping. All three listings clearly identify the seller type as private.


Understanding your results

Every dataset row contains structured fields capturing key listing metadata:

  • id: Unique identifier assigned by DBA.
  • title and url: Listing headline and canonical link on dba.dk.
  • price and currency: Asking price in Danish kroner (DKK).
  • location: Locality or town specified by the seller.
  • latitude and longitude: Geographic coordinates of the listing.
  • postedAt and scrapedAt: ISO 8601 UTC timestamps for publication and extraction.
  • sellerType and organisationName: Indicates private or dealer. For private sellers, organisationName is null.
  • shippingAvailable and buyNow: Booleans for delivery and instant checkout.
  • labels: Array of badges such as Privat, Fiks færdig, and Køb nu.

One record from our sample run (with imageUrls cut to its first entry):

{
    "id": "8870736",
    "title": "Apple iPhone 15 128 GB",
    "url": "https://www.dba.dk/recommerce/forsale/item/8870736",
    "price": 2800,
    "currency": "DKK",
    "location": "Charlottenlund",
    "postedAt": "2026-11-15T20:41:38+00:00",
    "latitude": 55.75534,
    "longitude": 12.57482,
    "imageUrls": [
        "https://images.dbastatic.dk/dynamic/default/item/8870736/4c3f2b13-4241-4d4d-ae15-14a3590ed4d3"
    ],
    "organisationName": null,
    "sellerType": "private",
    "shippingAvailable": true,
    "buyNow": true,
    "labels": [
        "Fiks færdig",
        "Køb nu",
        "Privat",
        "Fri fragt"
    ],
    "brand": "Apple",
    "tradeType": "Til salg",
    "matchedKeyword": "iphone",
    "scrapedAt": "2026-11-15T21:03:51.713890+00:00"
}
Enter fullscreen mode Exit fullscreen mode

Pro tips

  1. Leverage site-side price filters. Setting minPrice and maxPrice passes parameters directly to DBA. This discards out-of-budget items on the server before pagination begins.
  2. Combine multiple keywords safely. You can supply several queries in searchQueries. The Actor automatically tracks previously seen ad IDs and deduplicates listings so each unique item appears only once in the dataset.
  3. Filter for delivery when buying remotely. Set shippingOnly to true if you only want ads that support parcel delivery through DBA's shipping integration.
  4. Respect the pagination ceiling. DBA caps marketplace listings at 50 pagination pages (approximately 2,650 items per search). If your query exceeds this volume, split your search using targeted price intervals.
  5. Danish character matching is automatic. The keyword filter normalizes special Danish characters, ensuring searches for terms with or without characters like æ and ø match expected titles.
  6. Geographic analysis is built in. Because latitude and longitude are extracted for each listing, you can map items directly without requiring an additional geocoding step.

Troubleshooting

  • Zero rows with status SUCCEEDED. The search query returned no matching listings on DBA, or post-fetch filters excluded all results. Check the spelling of your keywords.
  • Zero rows with status FAILED. An invalid input configuration stops execution immediately. For instance, setting minPrice greater than maxPrice or omitting searchQueries triggers an upfront validation error.
  • Run stops before maxItems is reached. The search reached the end of available pages on DBA, or encountered the platform ceiling of 50 pages.
  • Missing business names. Private sellers on DBA do not have business names, so organisationName is intentionally null for private listings.

Next steps

For current pricing and details, see the Store page.

To automate your searches, configure an Apify schedule to run the Actor on a regular cron interval. Extracted datasets can be exported in formats including JSON, CSV, Excel, XML, and JSONL via the dataset API. You can also set up webhooks to alert external services whenever a collection run completes.

What Danish marketplace items are you tracking? Share your setup in the comments!

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

Top comments (0)