DEV Community

Cover image for How to Scrape Blocket Second-Hand Listings in Python with Blocket Scraper
ReventaData
ReventaData

Posted on Originally published at apify.com

How to Scrape Blocket Second-Hand Listings in Python with Blocket Scraper

By the end of this tutorial you will have a Python script that extracts second-hand listings from blocket.se into structured rows: title, price in SEK, location, seller type, shipping availability, memory size, brand, and photos.

Blocket is Sweden's marketplace for used goods, electronics, furniture, and vehicles. Blocket Scraper (reventadata/blocket-scraper) is the Apify Actor built to search its Torget marketplace and return clean listing rows without running a browser.

This guide runs the Actor from Python using the official Apify API client. The sample rows and results below come from a live run searching for second-hand iPhones across Sweden, not from invented data. ⏱️ This tutorial takes about 10 minutes to complete.


Prerequisites

You need three quick prerequisites:

  1. Python 3.11 or newer installed on your machine.
  2. A free Apify account, which you can register using an email address or your GitHub account.
  3. Your personal Apify API token, found under Settings > API & Integrations in Apify Console.

Install the Apify client and export your token:

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

No local browser setup or custom scraping infrastructure is needed. The Actor handles the collection for you.


What you'll achieve

You will configure and run a search on blocket.se from Python, pull the results into structured dictionaries, and inspect key marketplace attributes including price, seller category, and whether an item can be shipped.

You will see how to distinguish private individuals from company sellers (such as Blocket Nybegagnat), how to filter listings by county and price, and how to read coordinates when available. You will also see how the Actor handles listings with missing fields without failing the run.

The resulting script can be plugged into a price comparison workflow, automated alerts for newly posted electronics, or market research pipelines tracking Swedish second-hand goods. Only the search input needs to change.


Step 1: Open Blocket Scraper

Open the Blocket Scraper page on Apify Store. The Try for free button opens the Actor in Apify Console. For running it from Python via the API, you only need its technical identifier, reventadata/blocket-scraper.


Step 2: Configure your search

The search is configured with a concise set of input parameters:

  • searchQueries: a list of search terms, such as ["iphone"]. Each term is searched in turn across Torget.
  • category: optional top-level category slug, such as electronics, furniture-interior, or clothes-cosmetics. Default is any. Any unsupported value is refused before the run starts.
  • location: optional county slug covering Sweden's 21 counties (such as stockholm, skane, or vastra-gotaland). Default is any. Unsupported county values are refused before the run starts.
  • sellers: any (default), private for private sellers only, or company for companies carrying the site's 'Företag' label.
  • tradeType: sell (default, Säljes), giveaway (Bortskänkes), wanted (Köpes), or any.
  • minPrice and maxPrice: inclusive price bounds in SEK applied by the site. If minPrice is set higher than maxPrice, the Actor refuses the input before starting.
  • shippingOnly: boolean flag. When set to true, the Actor keeps only listings offering shipping (Kan skickas).
  • excludeForParts: boolean flag. Drops ads whose title indicates spare parts or account lockouts (Reservdel... or iCloud-låst).
  • requireKeywordMatch: boolean flag (default true). Ensures each search word appears in the ad title or brand.
  • maxItems: maximum total rows across all search terms (default 100).
  • maxPages: maximum result pages per search term (1 to 50, default 50).

To search Stockholm for private smartphone ads offering shipping with a price ceiling, your input would look like this:

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

Step 3: Run the Actor from Python

This complete script initialises the Apify client, starts reventadata/blocket-scraper with a search for second-hand iPhones, waits for completion, and prints a formatted summary row for each result:

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}")
Enter fullscreen mode Exit fullscreen mode

The Actor walks results one page at a time (53 items per page). Keep maxPages small during initial testing.


Step 4: Read the output

Running the script with maxItems: 10 prints ten lines; here are the first four lines from our live capture:

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
Enter fullscreen mode Exit fullscreen mode

Notice the variations: prices range from 750 SEK for an older iPhone 7 Plus up to 6,000 SEK for recent Pro Max devices. Some sellers offer integrated parcel shipping, while others specify local pickup only.


Understanding your results

Every item saved by Blocket Scraper contains 23 structured fields. The most important fields for data analysis include:

  • id and url: the unique listing identifier and canonical listing URL on blocket.se.
  • title and price: the ad heading and numeric asking price in SEK.
  • location, latitude, longitude: town or municipality, and geographic coordinates when provided.
  • isPrivate and isRetailer: boolean seller classification. Commercial dealers also carry their shop name in organisationName.
  • shippingAvailable, sellerPaysShipping, and buyNow: flags showing whether shipping or direct checkout is supported.
  • brand and memorySize: parsed device attributes when present (such as Apple and 256 GB).
  • labels: Swedish badge strings directly from the listing, such as Privat, Kan skickas, and Gratis frakt.

Here is one complete listing row copied verbatim from our test run (imageUrls cut 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"
}
Enter fullscreen mode Exit fullscreen mode

Pro tips and advanced usage

Here are several recommendations for running production extractions on Blocket:

  1. Narrow broad searches with price or county filters. Blocket limits search listings to 50 pages (at 53 items per page, a maximum of 2,650 ads per search). When scraping large categories, partition your queries by county or price brackets rather than relying on one query.
  2. Filter out damaged gear. Turn on excludeForParts: true if you only want functional devices. This drops listings with titles mentioning spare parts or account lockouts.
  3. Use keyword matching. The requireKeywordMatch setting (enabled by default) requires every query word to appear in the listing title or brand, filtering out accessory listings that merely mention the query in their body text.
  4. Separate commercial from private ads. Filter downstream or set sellers: "company" to study company sellers, or sellers: "private" to monitor peer-to-peer listings.
  5. Deduplication is automatic across terms. If you provide multiple terms in searchQueries, listings returned under multiple terms are saved only once.

Troubleshooting common issues

  • Zero rows, status SUCCEEDED: The query matched no active listings, or your combination of category, county, and price filters was too restrictive (0 results: page(s) loaded normally, but nothing matched). Verify your search terms directly on blocket.se.
  • Zero rows, status FAILED: The Actor was supplied with an invalid input (such as an empty searchQueries array, an unrecognized category or county slug, or a minPrice greater than maxPrice), or pages could not be read if the site refused the run. The status message specifies what happened.
  • Fewer rows than expected: Check the run logs using client.log(run.id).get(). The log records skipped items per filter, such as ads dropped for lacking query keywords or ads lacking shipping (duplicate listings across terms are skipped silently).

Blocket's terms of use govern automated collection, so ensure your data collection and processing comply with applicable terms and privacy laws.


Next steps

For current pricing and details, see the Store page.

To automate recurring searches, configure an Apify schedule to trigger the Actor at set intervals. Extracted datasets can be downloaded as JSON, CSV, Excel, XML, or NDJSON (dataset documentation). You can also attach an Apify webhook to receive alerts whenever new listings are extracted.

What second-hand items are you planning to track on Blocket? Let us know in the comments! 💬

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

Top comments (0)