A Python scraper for Blocket.se, Sweden's largest marketplace for second-hand items, powered by ScrapingAnt API.
- Scrape listings from multiple categories (phones, electronics, furniture, fashion, etc.)
- URL-based pagination support
- Export to CSV and JSON formats
- Automatic deduplication of listings
- Swedish badge detection (Kan skickas, Köp nu)
- Configurable request delays
- Python 3.8+
- ScrapingAnt API key (Get free API key)
Note: The ScrapingAnt free plan has a concurrency limit of 1 thread. For higher throughput, consider upgrading to a paid plan.
- Clone the repository:
git clone https://github.com/scrapingant/BlocketScraper.git
cd BlocketScraper- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set your ScrapingAnt API key:
export SCRAPINGANT_API_KEY="your_api_key_here"Scrape default categories (phones, electronics):
python main.pypython main.py -c phones computers gamingpython main.py -c phones -p 5 # Scrape 5 pagespython main.py --list-categoriespython main.py -o results.csv # Custom CSV filename
python main.py --json # Also export to JSONusage: main.py [-h] [-c CATEGORIES [CATEGORIES ...]] [-p PAGES] [-d DELAY]
[-o OUTPUT] [--json] [--list-categories] [--api-key API_KEY]
Options:
-c, --categories Categories to scrape (default: phones, electronics)
-p, --pages Max pages per category (default: 2)
-d, --delay Delay between requests in seconds (default: 1.0)
-o, --output Output CSV filename
--json Also export to JSON format
--list-categories List all available categories
--api-key ScrapingAnt API key (or use SCRAPINGANT_API_KEY env var)
| Category | Description |
|---|---|
| electronics | All electronics |
| phones | Smartphones & mobile phones |
| computers | Computers & laptops |
| photo-video | Cameras & video equipment |
| audio-video | Audio & video electronics |
| gaming | Gaming consoles & games |
| appliances | Home appliances |
| furniture | Furniture |
| tables-chairs | Tables & chairs |
| sofas | Sofas & couches |
| beds | Beds & mattresses |
| lamps | Lighting |
| fashion | All fashion |
| womens-clothing | Women's clothing |
| mens-clothing | Men's clothing |
| shoes | Shoes |
| watches | Watches |
| sports | Sports equipment |
| bikes | Bicycles |
| winter-sports | Winter sports gear |
| golf | Golf equipment |
| garden | Garden & outdoor |
| tools | Tools |
| kids | Children's items |
| toys | Toys |
| strollers | Strollers & prams |
| hobby | Hobbies |
| music-instruments | Musical instruments |
| collectibles | Collectibles |
| Field | Description |
|---|---|
| title | Listing title |
| price | Price in SEK |
| location | Seller location |
| listing_url | Full URL to listing |
| category | Category scraped |
| time_posted | Time since posting |
| can_ship | Shipping available |
| buy_now | Buy now option |
| image_url | Listing image URL |
| scraped_at | Scraping timestamp |
BlocketScraper/
├── config.py # Configuration settings
├── models.py # Data models
├── scraper.py # Main scraper logic
├── utils.py # Utility functions
├── main.py # CLI entry point
├── requirements.txt # Dependencies
├── output/ # Output directory
│ └── .gitkeep
└── README.md
MIT License