Skip to main content

Complete Guide: How to Scrape Blocket Listings Using Python

Run the Blocket Scraper Apify Actor from Python and extract second-hand ads from blocket.se with prices in SEK, seller flags, and shipping.

Updated 10 min readMarkdown
Complete Guide: How to Scrape Blocket Listings Using Python

Blocket is Sweden's marketplace for classified ads, covering second-hand electronics, furniture, clothing, and vehicles across the country. Extracting this marketplace inventory manually is tedious and impractical for continuous price monitoring, automated deal alerts, or structured market analysis.

This guide provides an end-to-end walkthrough on extracting Swedish second-hand marketplace listings from blocket.se using Python. You will learn how to search the Torget marketplace, filter by Swedish counties, narrow by seller type, and receive clean structured data ready for analysis. The tool used throughout this tutorial is Blocket Scraper (reventadata/blocket-scraper), an Apify Actor controlled directly from Python via the official Apify API client.

By following this guide, you will understand the configuration options supported by the Actor, how it enforces search constraints, how to handle the returned dataset rows, and how to automate continuous data collection. Everything shown in this tutorial uses verified metrics from a live run executed against blocket.se searching for second-hand iPhones across Sweden. You need only basic Python knowledge, an Apify account, and an API token to get started.


TL;DR

In this comprehensive tutorial, you will learn to run reventadata/blocket-scraper from Python with apify-client, pass search criteria (searchQueries, category, location, sellers, tradeType, and price bounds), and retrieve structured items containing prices in SEK, location data, seller classification, shipping status, and device metadata. You will also discover the 50-page (2,650 listings) ceiling enforced per search term, quality filtering switches for damaged goods, and recurring execution schedules. Find the Actor on its Blocket Scraper Store page.


Prerequisites and setup

To run the scraper from code, ensure your local environment satisfies these standard prerequisites:

  1. A working installation of Python 3.11 or newer on your machine.
  2. A free Apify account, created through the Apify homepage using either an email address or a GitHub account.
  3. Your personal Apify API token, which authenticates client requests. Locate it in Apify Console under Settings > API & Integrations.

Install the official Python client library and set your API token in the environment:

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

Refer to the official Apify API client for Python documentation for further background. No browser or local scraping setup is needed.


Understanding Blocket Scraper

Blocket Scraper automates search queries across blocket.se's primary second-hand marketplace, known as Torget. It processes search terms one by one, walking result pages and collecting listings into a consolidated Apify dataset. Each result page serves 53 individual listings.

The site itself natively applies several key filters: top-level categories, 21 regional counties, seller classification (private or company), ad type (such as for-sale or wanted), and inclusive price bounds. Passing these parameters directly to the search ensures that only matching ads are fetched. The Actor performs additional quality checks downstream, ensuring query keywords appear in ad titles, dropping ads marked as damaged or account-locked when requested, and deduplicating ads across multiple terms.

A key ceiling to keep in mind is that the site serves at most 50 pages of results (2,650 listings) for any given query. If your target query matches more listings than this limit, you should partition the search across distinct Swedish counties or narrower price brackets to achieve complete dataset coverage without leaving gaps in your market sample.


Step-by-step walkthrough

Step 1: Open the Actor

Navigate to the Blocket Scraper page on Apify Store. Clicking Try for free opens the Actor configuration screen in Apify Console. When interacting via Python, you reference the Actor's published name: reventadata/blocket-scraper.

Step 2: Choose the input

The Actor accepts several configuration fields through both the Console form and the Python API:

Field Description
searchQueries List of search phrases, e.g. ["iphone"]. Mandatory.
category Top-level category slug (e.g. electronics, furniture-interior). Default any.
location Swedish county slug (e.g. stockholm, skane, vastra-gotaland). Default any.
sellers Seller filter: any (default), private, or company (for listings carrying the site's 'Företag' label).
tradeType Listing type: sell (default), giveaway, wanted, or any.
minPrice, maxPrice Inclusive price boundaries in SEK.
shippingOnly Drop ads where the seller does not offer shipping (Kan skickas).
excludeForParts Drop ads indicating spare parts or account lockouts (Reservdel... / iCloud-låst).
requireKeywordMatch Verify query words appear in title or brand (default true).
maxItems Maximum rows saved across all terms (default 100).
maxPages Page limit per search term, clamped between 1 and 50 (default 50).

Unsupported enum values for category, location, sellers, or tradeType are refused before the run starts. Similarly, setting minPrice above maxPrice triggers immediate input validation refusal.

Here is an example input configuring a targeted search for private electronics in Stockholm with shipping:

{
    "searchQueries": ["iphone"],
    "category": "electronics",
    "location": "stockholm",
    "sellers": "private",
    "tradeType": "sell",
    "minPrice": 1000,
    "maxPrice": 8000,
    "shippingOnly": true,
    "maxItems": 20,
    "maxPages": 2
}

Step 3: Run the Actor from Python

Use the script below to initiate a run, wait for completion, and inspect the resulting records:

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: second-hand iPhones on Blocket
run_input = {
    "searchQueries": ["iphone"],
    "maxItems": 10,
    "maxPages": 1,
}

# 3. Start the Actor and wait for it to finish
run = client.actor("reventadata/blocket-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 line per listing
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"
    seller = "Private" if item.get("isPrivate") else ("Company" if item.get("isRetailer") else "Unknown")
    shipping = "shipping" if item.get("shippingAvailable") else "pickup only"
    print(f"{item.get('title')} | {price_str} | {item.get('location')} | {seller} | {shipping}")

Working with the API

The Python script uses the official apify-client library to manage the full extraction lifecycle. Calling client.actor("reventadata/blocket-scraper").call(...) packages your input dictionary into an execution request, triggers the Actor, and polls until execution completes. The returned run object is typed, exposing properties like status, default_dataset_id, and execution metadata.

Once the run reaches SUCCEEDED, the dataset items are retrieved via client.dataset(run.default_dataset_id).list_items().items. This produces a list of clean dictionaries. Running our sample script against blocket.se with maxItems: 10 returned ten rows; here are the first four lines:

Apple iPhone 15 Pro Max 256 GB | 6000 SEK | Skövde | Private | pickup only
iPhone 14 Pro max som ny ingen skada med laddare | 4200 SEK | Trelleborg | Private | shipping
Apple iPhone 7 plus 64 GB | 750 SEK | Göteborg | Private | shipping
Apple iPhone 11 Pro Max 256 GB | 1500 SEK | Saltsjö-Boo | Private | pickup only

You can iterate through these dictionaries to pipe data directly into PostgreSQL, store them in pandas DataFrames, or evaluate pricing rules. If a run terminates unexpectedly or yields zero rows, check the execution log with client.log(run.id).get(). Because the SDK provides asynchronous methods as well, you can embed the extraction inside event loops or fast web backends without blocking application threads.


Advanced usage patterns

For continuous monitoring or large-scale data aggregation, consider these advanced patterns:

  1. County Partitioning: Because blocket.se caps results at 50 pages (2,650 items), searching a national term like 'cykel' or 'soffa' will truncate after page 50. Loop through Sweden's 21 counties in separate Actor calls to fetch complete regional inventories. This approach prevents truncation while keeping each run focused and manageable.
  2. Excluding Damaged Hardware: When collecting price intelligence on functional devices, activate excludeForParts: true. This checks listing titles for phrases like Reservdel... or iCloud-låst and drops them before they enter your dataset, ensuring that non-functional spare-part devices do not distort your calculated price statistics.
  3. Filtering by Seller Segment: By setting sellers: "company", you isolate company sellers (such as Blocket Nybegagnat), allowing you to compare company listings carrying the site's 'Företag' label against peer-to-peer listings obtained via sellers: "private". This separation helps analysts evaluate professional merchant inventory alongside individual consumer postings across the marketplace.
  4. Keyword Match Enforcement: The default requireKeywordMatch: true setting ensures that every query token appears in the listing title or brand, filtering out accessory listings that match only on body text.
  5. Shipping Preference Segmentation: Use shippingOnly: true when building automated purchasing workflows that require remote delivery across Sweden, eliminating local pickup ads that require in-person collection.

Understanding your data

Each record in the dataset contains 23 standardized fields describing the listing:

  • Identifiers & URLs: id holds the Blocket ad identifier, while url provides the canonical ad link.
  • Pricing: price is a numeric asking price (or null when unpriced), and currency is always SEK.
  • Geographic Data: location gives the town or region. When available, latitude and longitude provide approximate location coordinates.
  • Seller Classification: isPrivate and isRetailer classify the listing source. When sold by a company, organisationName contains the store or business name.
  • Transaction Details: shippingAvailable, sellerPaysShipping, and buyNow report delivery and instant purchase support.
  • Item Specs: brand and memorySize provide extracted specifications for supported categories.

Below is a complete record taken verbatim from our live run (imageUrls shortened to its first entry):

{
    "id": "28290815",
    "title": "Apple iPhone 15 Pro Max 256 GB",
    "url": "https://www.blocket.se/recommerce/forsale/item/28290815",
    "price": 6000,
    "currency": "SEK",
    "location": "Skövde",
    "postedAt": "2026-11-15T20:44:50+00:00",
    "latitude": 58.38545,
    "longitude": 13.84409,
    "imageUrls": [
        "https://images.blocketcdn.se/dynamic/default/item/28290815/086cef5e-ec3a-4ab6-8af3-06cf800f69dc"
    ],
    "isPrivate": true,
    "isRetailer": false,
    "shippingAvailable": false,
    "sellerPaysShipping": false,
    "buyNow": false,
    "labels": [
        "Privat"
    ],
    "brand": "Apple",
    "memorySize": "256 GB",
    "organisationName": null,
    "tradeType": "Säljes",
    "matchedKeyword": "iphone",
    "site": "SE",
    "scrapedAt": "2026-11-15T21:03:25.576850+00:00"
}

Troubleshooting guide

When configuring and running Blocket Scraper, keep these common scenarios in mind:

  • Run finishes with status SUCCEEDED but 0 rows: The search query or filter combination matched no active ads on Torget, or matching ads were dropped by filters (0 results: page(s) loaded normally, but nothing matched). Confirm your query terms directly on blocket.se.
  • Run terminates with status FAILED and 0 rows: An input constraint was violated before execution began (such as empty searchQueries, an unknown category or county slug, or setting minPrice higher than maxPrice), or pages could not be read if the site refused the run. The error message details the exact field or issue.
  • Fewer rows than requested: The search may have exhausted all available result pages, or post-fetch filters (such as shippingOnly or requireKeywordMatch) excluded listings that did not satisfy criteria. Review filter exclusion counts in the run log.

Always check blocket.se terms of use and local regulations to ensure your automated data extraction remains compliant.


Best practices

Follow these best practices to ensure reliable automated extraction:

  1. Start with limited runs: Always validate new filter combinations with small maxPages and maxItems values before scraping large volumes. This confirms that your filters produce expected listings before you initiate wider queries.
  2. Rely on site-level filtering: Use minPrice, maxPrice, category, and location to filter server-side rather than fetching broad categories and discarding rows downstream. This minimizes unnecessary page processing and accelerates extraction speed.
  3. Handle optional fields defensively: Fields like latitude, longitude, brand, and memorySize will be null on listings where the seller or category does not provide them. Write defensive parser checks in your consumer applications to prevent runtime errors when inspecting missing attributes.

Conclusion and next steps

For current pricing and details, see the Store page.

To automate recurring extractions, configure an Apify schedule to run this Actor at regular intervals. Datasets can be exported in JSON, CSV, Excel, XML, or NDJSON formats (dataset documentation), and you can configure an Apify webhook to alert your backend when an extraction completes.

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

About the author

  • Hi, I'm the engineer behind ReventaData. I build pay-per-event Apify Actors that turn public marketplace, classifieds, jobs and real-estate sites into clean, reliable datasets. Here on Hashnode, I share practical tutorials on collecting structured web data with Python and Apify, and on putting it to work: price tracking, lead lists and market analysis. Explore our turnkey scrapers: https://apify.com/reventadata

No comments yet. Be the first to comment.