DEV Community

Cover image for How to Pull Keejob Job Listings into Python with Keejob Scraper
ReventaData
ReventaData

Posted on Originally published at apify.com

How to Pull Keejob Job Listings into Python with Keejob Scraper

A job board lists many openings for one search phrase, one results page at a time. To keep the title, company, location and posting date of each listing in a spreadsheet you copy them by hand. This tutorial replaces that with a short Python script. It runs one search phrase on Keejob in Tunisia and returns one row per result.

The tool is the Keejob Scraper Actor (reventadata/keejob-scraper). You call it from Python with the official apify-client package. The Actor reads public pages and needs no login. It is not affiliated with Keejob.

By the end you will have a script that runs one search, saves the rows to a JSON file and turns them into a CSV file.


Prerequisites

  1. Python 3.11 or newer.
  2. The Apify API client for Python:
pip install -U "apify-client~=3.0"
Enter fullscreen mode Exit fullscreen mode
  1. An Apify account and your personal API token, set as an environment variable:
export APIFY_API_TOKEN="your_apify_token_here"
Enter fullscreen mode Exit fullscreen mode

The Actor needs no login. The token is only for the call from your script.


What you'll achieve

Each row is one result of the Keejob public job search in Tunisia. The fields are:

  • id: the identifier published by the site.
  • title: the job title as published.
  • company: the employer name published by the site. It can be empty.
  • location: the published location. It can be empty.
  • date: the published posting date as text. It can be empty.
  • url: the public job listing URL.
  • matchedQuery: the phrase that found the item.
  • scrapedAt: an ISO 8601 timestamp of when the row was stored.

Example use case: search a phrase such as engineer and keep the title, company, location and posting date of each listing in a file, then run the same search another day and compare the two files by scrapedAt.


Step 1: Open the Actor

Open the Keejob Scraper page on the Apify Store to read its description. This guide calls the Actor from Python, so the ID you need is reventadata/keejob-scraper.


Step 2: Set the inputs

Field Type What it does
query string Required. The phrase to look up in the Keejob public job search, for example engineer.
maxItems integer Maximum number of results to save to the dataset. Minimum 1. Default 25.

query decides what is searched. maxItems decides when the Actor stops saving rows. A small value such as 10 is a good first test, because you can read every row.


Step 3: Run it from Python

import json
import os

from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_API_TOKEN"])

run_input = {"query": "engineer", "maxItems": 10}

run = client.actor("reventadata/keejob-scraper").call(run_input=run_input)
if run is None:
    raise SystemExit("The run did not start.")

print("Run status:", run.status)
items = client.dataset(run.default_dataset_id).list_items().items

for item in items:
    print(
        item["title"],
        "|",
        item.get("company"),
        "|",
        item.get("location"),
        "|",
        item.get("date"),
        "|",
        item.get("url"),
    )

with open("keejob-engineer-rows.json", "w", encoding="utf-8") as f:
    json.dump(items, f, indent=2, ensure_ascii=False)
Enter fullscreen mode Exit fullscreen mode

The call method starts the Actor and waits for it to finish. The run object has a status and the ID of the dataset that stores the rows. list_items().items returns the rows as a list of dictionaries. The loop prints one line per result and the last lines save every row to keejob-engineer-rows.json.

If the run did not start, call returns nothing, and the script stops with a message instead of failing later on an empty value. The loop reads company, location, date and url with get because a row can have optional fields empty.


Step 4: Read one row

The three rows below are the first three of the example run of 2026-11-27 (input {"query": "engineer", "maxItems": 10}, 4 rows in total). They are shown whole and unedited.

[
  {
    "id": "240408",
    "title": "Incoming Quality Inspection (IQC) Engineer",
    "company": "HUBER SUHNER",
    "location": "Sousse Ville, Sousse",
    "date": "27 novembre 2026",
    "url": "https://www.keejob.com/offres-emploi/240408/incoming-quality-inspection-iqc-engineer/?source=search",
    "matchedQuery": "engineer",
    "scrapedAt": "2026-11-27T15:35:14.047336+00:00"
  },
  {
    "id": "249298",
    "title": "Data Engineer",
    "company": "CODWAY",
    "location": "Tunis",
    "date": "30 octobre 2026",
    "url": "https://www.keejob.com/offres-emploi/249298/data-engineer-hf/?source=search",
    "matchedQuery": "engineer",
    "scrapedAt": "2026-11-27T15:35:14.047336+00:00"
  },
  {
    "id": "249938",
    "title": "Laboratory Engineer",
    "company": "FRESENIUS KABI",
    "location": "Beni Khalled, Nabeul",
    "date": "16 novembre 2026",
    "url": "https://www.keejob.com/offres-emploi/249938/laboratory-engineer/?source=search",
    "matchedQuery": "engineer",
    "scrapedAt": "2026-11-27T15:35:14.047336+00:00"
  }
]
Enter fullscreen mode Exit fullscreen mode

Notes on the fields:

  • The date value is French-language text as the site published it, so parse it yourself if you need a date object.
  • company, location and date can be empty (null), so read them with item.get("name").
  • matchedQuery repeats the phrase you searched.
  • scrapedAt is a UTC timestamp. Every row of one run carries the same value in the example above.
  • id identifies the listing, and url links to its public page.

Understanding your results

A row is a copy of what the site shows on one result card: a job title, an employer name when present, a location when present, a posting date string and a link. Nothing in the row is calculated or translated by the Actor. That has two practical consequences when you load the file into Python or a spreadsheet.

First, date is a string in French, such as "27 novembre 2026", written the way the site published it. If you want to sort or filter by posting date, parse that text yourself and keep the original string alongside your parsed value so any change in format is easy to spot later.

Second, a row only holds what the card published. If a card omits company, location or date, the field is null, so code that must not stop on a missing value should read those fields with item.get("name") and provide a fallback when formatting output.


Pro tips and advanced usage

  • Save a CSV. The second script reads the JSON file back and writes a CSV with the columns you choose:
import csv
import json

with open("keejob-engineer-rows.json", encoding="utf-8") as f:
    items = json.load(f)

columns = ["id", "title", "company", "location", "date", "matchedQuery", "scrapedAt", "url"]
with open("keejob-engineer-rows.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.DictWriter(f, fieldnames=columns)
    writer.writeheader()
    for item in items:
        writer.writerow({name: item.get(name) for name in columns})
Enter fullscreen mode Exit fullscreen mode
  • Keep one file per day. Put the date in the file name and compare files later with scrapedAt.
  • Try several phrases. Run the script once per phrase. matchedQuery tells you which phrase produced each row when you merge the files.
  • Start small. Keep maxItems low until the first rows look right, then raise it.
  • Check a link by hand. Open a few url values in a browser and compare the title, company and date with the row, now and then.
  • Dedupe on id. A listing can appear under two phrases when you merge files, so key merged data by id.

Limits to know

  • One search phrase is read per run, and one results page is read per search.
  • A phrase with no public results stores no rows.
  • query is required and can be at most 120 characters. maxItems must be 1 or more, and defaults to 25.
  • Only fields the site publishes on the search card are returned. Nothing sits behind a login, and no detail pages are read.
  • The same id is stored once per run.

Troubleshooting common issues

  • The run stops with a message and no rows: check that query is not empty and is within 120 characters, and that maxItems is at least 1.
  • The run succeeds with no rows: the phrase had no public results. Try a broader phrase.
  • The run fails with a message about the site: the site refused the run or returned an unexpected shape. Wait and run it again. The run log shows the message the Actor wrote.
  • A row shows an empty field: the site did not publish it on that card. Read it with item.get("name") as shown above.
  • The status is not a success: read the run log in the Apify Console. The Actor writes the reason there.

Next steps

Run the script on a schedule with your own cron job or a scheduler, keep the files, and compare them across dates. Try other phrases and a larger maxItems. The Apify Python client documentation covers the rest of the client.

For current pricing and details, see the Store page.

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

Top comments (0)