Skip to content

Latest commit

 

History

History
88 lines (63 loc) · 2.36 KB

python.md

File metadata and controls

88 lines (63 loc) · 2.36 KB

Stepstone.de Jobs Scraper — Python examples

Call the Stepstone.de Jobs Scraper from Python with the official apify-client.

Install

pip install apify-client

Basic run — keyword + city

from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")

run = client.actor("logiover/stepstone-de-jobs-scraper").call(run_input={
    "keyword": "software engineer",
    "location": "berlin",
    "sortBy": "date",
    "maxPagesPerSearch": 4,
})

for job in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(job["title"], "—", job["companyName"], "—", job.get("salary"))

Multiple searches into a pandas DataFrame

import pandas as pd
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")

run = client.actor("logiover/stepstone-de-jobs-scraper").call(run_input={
    "searches": [
        {"keyword": "product manager", "location": "frankfurt-am-main"},
        {"keyword": "data analyst",    "location": "muenchen"},
        {"keyword": "devops",          "location": ""},
    ],
    "sortBy": "date",
    "maxPagesPerSearch": 3,
})

rows = list(client.dataset(run["defaultDatasetId"]).iterate_items())
df = pd.DataFrame(rows)
print(df[["title", "companyName", "location", "salary", "datePosted"]].head(20))

# Which companies are hiring the most?
print(df["companyName"].value_counts().head(10))

Full descriptions + export to CSV

from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")

run = client.actor("logiover/stepstone-de-jobs-scraper").call(run_input={
    "keyword": "pflegekraft",
    "location": "hamburg",
    "fetchJobDetails": True,
    "maxPagesPerSearch": 5,
})

with open("stepstone-jobs.csv", "wb") as f:
    f.write(client.dataset(run["defaultDatasetId"]).download_items(item_format="csv"))

print("Saved stepstone-jobs.csv")

Read token from an environment variable

import os
from apify_client import ApifyClient

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

run = client.actor("logiover/stepstone-de-jobs-scraper").call(run_input={})
items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
print(len(items), "newest German jobs")

Keep your token in APIFY_TOKEN or a secrets manager instead of committing it.