Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 1.45 KB

File metadata and controls

53 lines (39 loc) · 1.45 KB

Python — Blocket.se Scraper

Call the hosted Blocket.se Scraper from Python using the official apify-client.

Install

pip install apify-client

Run and fetch results

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("logiover/blocket-se-scraper").call(run_input={
    "searchQuery": "Volvo",
    "category": "car",
    "location": "0.300001",  # Stockholm
    "maxResults": 100,
})

items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
print(f"Got {len(items)} listings")
for x in items[:10]:
    print(x["title"], x.get("priceValue"), x.get("location"))

Used cars into pandas

import pandas as pd
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("logiover/blocket-se-scraper").call(run_input={
    "searchQuery": "V70",
    "category": "car",
    "maxResults": 300,
})

df = pd.DataFrame(client.dataset(run["defaultDatasetId"]).list_items().items)
print(df[["make", "model", "year", "mileageValue", "fuel", "priceValue"]].head())

Notes

  • Get your token from the Apify Console.
  • All input fields are optional; {} browses all of Sweden.
  • Category car / mc / boat populates the vehicle fields.
  • Full field reference: see the main README.