Add the Jobnet search reader, which reads jobnet.dk's backend with the x-csrf header and 100 ads a page
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
018a1ad895
commit
0ed0360b09
5 files changed
+545
No files matched your search
@@ -0,0 +1,160 @@
|
||||
"""Jobnet: Denmark's state job portal (jobnet.dk), searched through the
|
||||
backend of its own site, `/bff/FindJob/Search`; no key, no login.
|
||||
|
||||
Checked live on 2026-10-03. The endpoint answers 401 without the header
|
||||
`x-csrf: 1` and 200 with it, whatever its value; every request sends it
|
||||
through `get`. jobnet.dk has no robots.txt: `/robots.txt` redirects to a login
|
||||
page. `regions` is one of the five region ids in `REGIONS`, empty for all of
|
||||
Denmark. 100 results a page (`resultsPerPage`), `pageNumber` from 1, ordered
|
||||
by `PublicationDate`, and the page after the 100th answers an empty list, so
|
||||
a search reads 10,000 results at most. The answer states `totalJobAdCount`,
|
||||
and every ad has its whole text as HTML, so the list has the full text.
|
||||
`searchString` is a loose match with no phrase syntax: a quoted phrase finds
|
||||
nothing.
|
||||
|
||||
Mostly Danish public sector and small employers; about a fifth of the ads
|
||||
only link to the employer's own page (`jobAdUrl`), which is then the role's
|
||||
`url`; the rest open Jobnet's own page for the ad. `country` is written in
|
||||
Danish ("Tyskland"), and a few ads are abroad. An ad states one place, the
|
||||
municipality or else the postal district, and none when its address is
|
||||
blank. `applicationDeadline`, with `1900-01-01` for none, is kept in `raw`.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._contract import Ask, Fields, Filters, Place, Reads
|
||||
from ._countries import code_of
|
||||
from ._shared import Get, Page, Row, html_text, is_web_url, only, parse_dt, place
|
||||
|
||||
NAME = "jobnet"
|
||||
LABEL = "Jobnet (Denmark)"
|
||||
RANK = 40
|
||||
|
||||
READS = Reads(
|
||||
scope="search", listing="paged", page_size=100, ceiling=10000,
|
||||
text="listing", complete="stated",
|
||||
filters=Filters(query="one", place="one"),
|
||||
places="one",
|
||||
fields=Fields(posted="trusted", country="stated"),
|
||||
robots="read: jobnet.dk has no robots.txt, /robots.txt redirects to a login; "
|
||||
"/bff/FindJob/Search answers 401 without the header x-csrf: 1 and "
|
||||
"200 with it (checked 2026-10-03)")
|
||||
|
||||
#: Saved param -> the filter dimension it fills.
|
||||
PARAMS = {"q": "query", "region": "place"}
|
||||
|
||||
SEARCH = "https://jobnet.dk/bff/FindJob/Search"
|
||||
|
||||
#: What the backend wants on every request; any value does.
|
||||
HEADERS = {"x-csrf": "1"}
|
||||
|
||||
#: The five regions as the `regions` facet of an answer names them, with the
|
||||
#: label the site shows. "" is all of Denmark and is not a key here.
|
||||
REGIONS: dict[str, str] = {
|
||||
"HovedstadenOgBornholm": "Hovedstaden og Bornholm",
|
||||
"Midtjylland": "Midtjylland",
|
||||
"Syddanmark": "Syddanmark",
|
||||
"OevrigeSjaelland": "Øvrige Sjælland",
|
||||
"Nordjylland": "Nordjylland",
|
||||
}
|
||||
|
||||
#: The countries of the `countries` facet (2026-10-03), as the ads write them
|
||||
#: in Danish, to ISO codes; a name not here is read as an English one.
|
||||
COUNTRIES: dict[str, str] = {
|
||||
"Danmark": "DK", "Grønland": "GL", "Grækenland": "GR", "Norge": "NO",
|
||||
"Tyskland": "DE", "Spanien": "ES", "Sverige": "SE", "Malta": "MT", "Østrig": "AT",
|
||||
"Amerikas Forenede Stater (USA)": "US", "Cypern": "CY", "Portugal": "PT",
|
||||
"Bulgarien": "BG", "Schweiz": "CH", "Marokko": "MA", "Nederlandene": "NL",
|
||||
"Vietnam": "VN", "Canada": "CA", "Tjekkiet": "CZ", "Finland": "FI", "Færøerne": "FO",
|
||||
"Indien": "IN", "Malaysia": "MY", "Filippinerne": "PH", "Polen": "PL",
|
||||
"Saudi Arabien": "SA", "Singapore": "SG", "Storbritannien": "GB", "Frankrig": "FR",
|
||||
"Italien": "IT", "Irland": "IE", "Belgien": "BE", "Island": "IS", "Estland": "EE",
|
||||
"Letland": "LV", "Litauen": "LT", "Ungarn": "HU", "Rumænien": "RO", "Kroatien": "HR",
|
||||
"Tyrkiet": "TR", "Kina": "CN", "Japan": "JP", "Australien": "AU", "Luxembourg": "LU",
|
||||
}
|
||||
|
||||
#: `applicationDeadline` of an ad with no deadline.
|
||||
_NO_DEADLINE = "1900-01-01"
|
||||
|
||||
|
||||
def allowed(slug: str) -> Callable[[str], bool]:
|
||||
return only("jobnet.dk")
|
||||
|
||||
|
||||
def clean_params(params: dict[str, Any]) -> dict[str, Any]:
|
||||
"""The saved params of a search: `q` and `region`, the id of one of the
|
||||
five regions or empty for all of Denmark."""
|
||||
region = str(params.get("region") or "").strip()
|
||||
if region and region not in REGIONS:
|
||||
raise ValueError("region is empty or one of " + ", ".join(REGIONS))
|
||||
return {"q": params["q"], "region": region}
|
||||
|
||||
|
||||
def page(get: Get, slug: str, cursor: Any, ask: Ask) -> Page:
|
||||
"""One page of a search, newest first; the cursor is the page number,
|
||||
from 1. The next page follows a full page while it is within the
|
||||
ceiling. An answer without `jobAds` is not a search result and raises,
|
||||
since an empty list would read as a search that ran out."""
|
||||
region = str(ask.places[0] if ask.places else ask.params.get("region") or "")
|
||||
if region and region not in REGIONS:
|
||||
raise ValueError(f"jobnet region {region!r} is not one of the ids in REGIONS")
|
||||
size, ceiling = READS.page_size or 100, READS.ceiling or 10000
|
||||
number = int(cursor or 1)
|
||||
query: dict[str, Any] = {
|
||||
"searchString": ask.query or str(ask.params.get("q") or ""),
|
||||
"orderType": "PublicationDate", "resultsPerPage": size, "pageNumber": number}
|
||||
if region:
|
||||
query["regions"] = region
|
||||
data = json.loads(get(SEARCH + "?" + urlencode(query), headers=HEADERS))
|
||||
if not isinstance(data, dict) or not isinstance(data.get("jobAds"), list):
|
||||
raise ValueError("jobnet: the answer has no jobAds")
|
||||
ads = [ad for ad in data["jobAds"] if isinstance(ad, dict)]
|
||||
total = data.get("totalJobAdCount")
|
||||
more = len(ads) >= size and (number + 1) * size <= ceiling
|
||||
return (data, [{"id": str(ad.get("jobAdId") or "")} for ad in ads],
|
||||
total if isinstance(total, int) else None, number + 1 if more else None)
|
||||
|
||||
|
||||
def _text(fragment: Any) -> str:
|
||||
return strip_html(str(fragment or "")).strip()
|
||||
|
||||
|
||||
def _country(name: str) -> str | None:
|
||||
"""The ISO code of an ad's country, `DK` when it names none."""
|
||||
name = name.strip()
|
||||
return (COUNTRIES.get(name) or code_of(name) or None) if name else "DK"
|
||||
|
||||
|
||||
def rows(decoded: Any, slug: str) -> list[Row]:
|
||||
out: list[Row] = []
|
||||
for ad in decoded.get("jobAds") or []:
|
||||
ident = str(ad.get("jobAdId") or "").strip()
|
||||
title = _text(ad.get("title"))
|
||||
if not ident or not title:
|
||||
continue
|
||||
link = str(ad.get("jobAdUrl") or "").strip()
|
||||
town = _text(ad.get("municipality") or ad.get("postalDistrictName"))
|
||||
places: list[Place] = [place(town)] if town else []
|
||||
row: Row = {
|
||||
"source_id": ident,
|
||||
"title": title,
|
||||
"company": _text(ad.get("hiringOrgName")),
|
||||
"url": link if is_web_url(link) else f"https://jobnet.dk/find-job/{ident}",
|
||||
"places": places,
|
||||
"location": town,
|
||||
"country": _country(str(ad.get("country") or "")),
|
||||
"posted": parse_dt(ad.get("publicationDate")),
|
||||
"description": html_text(ad.get("description")),
|
||||
}
|
||||
deadline = str(ad.get("applicationDeadline") or "")
|
||||
if deadline and not deadline.startswith(_NO_DEADLINE):
|
||||
row["applicationDeadline"] = deadline
|
||||
out.append(row)
|
||||
return out
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"jobAds": [],
|
||||
"totalJobAdCount": 20684,
|
||||
"searchString": ""
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
{
|
||||
"jobAds": [
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Frederiksberg",
|
||||
"postalCode": 2000,
|
||||
"postalDistrictName": "Frederiksberg",
|
||||
"hiringOrgName": "Mywok ApS",
|
||||
"occupation": "Kok",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/68c9d4ce-3dfe-45ec-aa21-6ea6bed91035",
|
||||
"jobAnnouncementTypeName": "Hotjob",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "5e6a1854-803f-4102-9dcc-e7cffeabb278",
|
||||
"jobAdUrl": "",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": "",
|
||||
"cvr": "45458962",
|
||||
"title": "kok til asiatisk takeaway",
|
||||
"description": "<p>Er du passioneret omkring kinesisk mad? har du et skarpt øje for detaljer og elsker at arbjde i et pulserende, hurtigt miljø? Så er du måske vores nye kollega!</p><p>Mywok i frederiksberg søger 2 dygtige og engageret kok til vores køkken, der kan bringe deres erfaring og kreativitet til vores team.</p><p>Arbejdsopgaver:</p><p>Forberedelse og tilberedning af asiatisk retter at opretholde en høj standard for renlighed oh hygiejne i køkkenet bidrage med ideer til menuopdateringer og sæsonbestemte tilbud.</p><p>Dine kvalifikationer</p><p>Du har erfaring fra lignende stillinger, og du er fortrolig med at arbejde i et travlt køkken, Du har en solid viden om og erfaring med at lave asiatisk retter.</p><p>Du arbejder effektivt og kan håndtere tralhed i køkkenet. Du er ansvarlig og kan arbejde selvstændigt såvel som i et team</p>",
|
||||
"applicationDeadline": "2026-10-31T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2026-10-31T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": false,
|
||||
"publicationDate": "2026-10-03T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Gladsaxe",
|
||||
"postalCode": 2860,
|
||||
"postalDistrictName": "Søborg",
|
||||
"hiringOrgName": "Simba Automation APS",
|
||||
"occupation": "Taxichauffør",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/4ce98c22-8794-4105-bd71-8bf18a47bd00",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "db54d22c-3742-4bc7-9100-c2c3edf4cea3",
|
||||
"jobAdUrl": "",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": "",
|
||||
"cvr": "39504065",
|
||||
"title": "Taxichauffør - Fuldtid, Deltid, Afløser",
|
||||
"description": "<p><strong>En af de gamle vognmænd fra 1990'erne søger taxichauffører</strong></p>\n<p>Vi søger <strong>Stabil, Flittig, Professionel, Venlige og Erfarne</strong> taxichauffører til at blive en del af vores virksomhed. Som taxichauffør vil dine ansvarsområder omfatte at hente kunder, transportere dem til deres destinationer og håndtere betalinger. Dit mål er at sikre sikre og behagelige rejser for passagererne. Køretøjets vedligeholdelse hold taxaen ren og i fremragende stand.</p>\n<p>Vi tilbyder både <strong>Deltids og Fuldtidsstillinger samt Weekendvagter.</strong> Desuden har vi både <strong>El-Taxier og Diesel-Taxier</strong>. Muligvis få taxier alene med hjem!</p>\n<p><strong>Krav:</strong></p>",
|
||||
"applicationDeadline": "2026-11-23T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2026-11-23T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": false,
|
||||
"publicationDate": "2026-10-02T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"postalCode": 2610,
|
||||
"postalDistrictName": "Rødovre",
|
||||
"hiringOrgName": "OLSEN METALTRYKKERI A/S",
|
||||
"occupation": "Maskinoperatør",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/b8ecaf41-d248-4232-ad58-9b3a6a8a4c18",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "f2ed4f3d-03bc-4021-a4f2-48d7fa13c521",
|
||||
"jobAdUrl": "",
|
||||
"hasLogo": true,
|
||||
"workPlaceAddress": "",
|
||||
"cvr": "73418216",
|
||||
"title": "Operatører til metalproduktion",
|
||||
"description": "<p>Til mindre metalproduktion i Rødovre (35 pers.) søger vi nye kollegaer. Du har erfaring med betjening af maskiner til forarbejdning af metal. Gerne betjening af CNC styrede maskiner på operatørniveau.</p><p>Det vi fremstiller er meget nicheorienteret så vi forventer ikke at du kender til vores maskiner, men det er vigtigt at du har en baggrund i metalindustrien så du forstår hvad det handler om når man arbejder med metal.</p><p>Du vil blive oplært i de aktuelle maskiner og vi kan ud over en spændende arbejdsdag med mange forskellige opgaver, tilbyde gode kollegaer, fleksible arbejdstider og et godt arbejdsmiljø.</p><p></p>",
|
||||
"applicationDeadline": "2026-10-30T18:08:37+01:00",
|
||||
"applicationDeadlineSort": "2026-10-30T18:08:37+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": false,
|
||||
"publicationDate": "2026-10-02T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Roskilde",
|
||||
"postalCode": 4000,
|
||||
"postalDistrictName": "Roskilde",
|
||||
"hiringOrgName": "Roskilde Kommune",
|
||||
"occupation": "Social- og sundhedshjælper",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/6c4558de-7fdd-4de1-921a-bd1d6ab4fe6d",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": true,
|
||||
"jobAdId": "7a79c8ca-9e9b-4a63-af64-8ed59de8ce43",
|
||||
"jobAdUrl": "https://candidate.hr-manager.net/ApplicationInit.aspx?cid=359&ProjectId=206245&MediaId=5",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": "Maglehøjen 6 ",
|
||||
"cvr": "29189404",
|
||||
"title": "Talentech - Roskilde Syd 2 søger timelønnede kolleger til den udekørende hjemmepleje",
|
||||
"description": "<p>Vi dækker områderne omkring Gartnervang og Æblehaven.</p>\n<p>Arbejdsopgaverne vil indeholde personlig pleje, samt praktisk hjælp, i borgers egen hjem.</p>\n<ul>\n<li>Du behøver ikke kørekort, men du skal kunne cykle og evt. medbringe din egen.</li>\n<li>Du skal gøre dig forståelig i dansk på skrift og tale.</li>\n<li>Du skal kunne møde kl 7.00 og gerne kunne arbejde hver anden weekend.</li>\n<li>Der vil være god introduktion med bl.a. forflytningsundervisning og undervisning i vores omsorgssystem.</li>\n</ul>\n<p>Vi tilbyder:</p>\n<ul>\n<li>Gode kolleger med fagligt fællesskab, høj tværfaglighed og godt humør.</li>\n<li>Stillinger som er præget af selvstændighed.</li>\n<li>Spændende og udviklende job, hvor alle hjælper hinanden og har ledelsesmæssig opbakning.</li>\n<li>Et spændende og alsidigt arbejde.</li>\n<li>En grundig introduktion.</li>\n</ul>\n<p>Vi bor på Maglehøjen 6, 4000 Roskilde .</p>",
|
||||
"applicationDeadline": "2026-10-19T00:00:00+02:00",
|
||||
"applicationDeadlineSort": "2026-10-19T00:00:00+02:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-10-03T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Haderslev",
|
||||
"postalCode": 6100,
|
||||
"postalDistrictName": "Haderslev",
|
||||
"hiringOrgName": "LINDAB",
|
||||
"occupation": "Produktionsmedarbejder",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/a58222c2-f8c8-4794-832f-8d8806408129",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "070b2b8b-8088-42be-a6a0-38b6a7deec26",
|
||||
"jobAdUrl": "https://www.sydjob.dk/Job/Detaljer/9150398/produktionsmedarbejder-med-handvarksmassig-er",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": " ",
|
||||
"cvr": "33124228",
|
||||
"title": "Produktionsmedarbejder med håndværksmæssig erfaring",
|
||||
"description": "<p>Produktionsmedarbejder med håndværksmæssig erfaring</p>\n<p>Er du praktisk anlagt, har du hænderne godt skruet på, og trives du med en hverdag, hvor der bliver arbejdet med metal og produktion fra bunden? Så er det måske dig, vi leder efter.</p>\n<p>Vi søger medarbejdere til vores afdeling, hvor vi fremstiller og samler vores produkter helt fra bunden. Det er en alsidig produktionsafdeling, hvor arbejdsdagen byder på forskellige former for håndværks- og produktionsopgaver.</p>\n<p>Du kommer blandt andet til at arbejde med:</p>\n<p>Valsning<br>\nTrådsvejsning<br>\nPunktsvejsning<br>\nKantkørsel<br>\nBukning<br>\nKalibrering<br>\nSamling og bearbejdning af produkter<br>\nDiverse håndværksmæssige og produktionsrelaterede opgaver</p>",
|
||||
"applicationDeadline": "2026-10-15T23:59:00+02:00",
|
||||
"applicationDeadlineSort": "2026-10-15T23:59:00+02:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-10-03T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Randers",
|
||||
"hiringOrgName": "Logos Payment Solutions A/S",
|
||||
"occupation": "Servicetekniker",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/d71b4a9c-8367-4afa-bf2a-5178b856e591",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "0be3d76e-fee8-48a1-a783-72882dcd1502",
|
||||
"jobAdUrl": "https://www.logospayments.com/da/karriere/",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": " ",
|
||||
"cvr": "26393647",
|
||||
"title": "Service tekniker Midtjylland (DK) – Logos Payment Solutions",
|
||||
"description": "<p><strong>Service tekniker Midtjylland (DK) – Logos Payment Solutions</strong></p>\n<p>Selvstændigt job med frihed under ansvar Logos Payment Solutions A/S søger en servicetekniker til installation og service af betalingsløsninger på tankstationer og vaskehaller i Midt- og Nordjylland.</p>\n<p>Du bliver en del af et landsdækkende team på ca. 30 teknikere og får en selvstændig hverdag med udgangspunkt fra din bopæl. Du tilknyttes vores afdeling i Randers og får adgang til sparring, reservedele og gode kollegaer.</p>\n<p>Vi tilbyder:</p>\n<p>• Grundig oplæring og sidemandsoplæring</p>\n<p>• Servicevogn, værktøj, PC og telefon</p>\n<p>• Konkurrencedygtig løn og frihed under ansvar</p>\n<p>• Et uformelt og positivt arbejdsmiljø</p>\n<p>📌 Vi søger dig, der er uddannet elektriker med erfaring, er løsningsorienteret og trives med kundekontakt og varierende arbejdsdage.</p>",
|
||||
"applicationDeadline": "2027-01-03T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2027-01-03T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-10-03T00:00:00+02:00"
|
||||
}
|
||||
],
|
||||
"totalJobAdCount": 57,
|
||||
"searchString": "data science"
|
||||
}
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"jobAds": [
|
||||
{
|
||||
"country": "Tyskland",
|
||||
"hiringOrgName": "Vereinigte Hagelversicherung VVaG",
|
||||
"occupation": "Rådgivende konsulent",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/5bfad078-c6d7-4460-9e65-1d84bce5e650",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "bf2403a6-57b6-4b71-b27c-8847e9f3cf80",
|
||||
"jobAdUrl": "https://germantechjobs.de/jobs/Vereinigte-Hagelversicherung-VVaG-Senior-Data-Analyst-mwd?utm_source=mygoogle_table_results&utm_medium=mygoogle_table_results",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": "Wilhelmstraße 25 ",
|
||||
"cvr": "31417619",
|
||||
"title": "Senior Data Analyst (m/w/d)",
|
||||
"description": "<p>To apply for this position, please send your CV and a short motivation letter to jobapplication@devitjobs.com - we only accept applications sent this way.</p>\n<p><strong>Anforderungen</strong></p>\n<p><strong>Muss:</strong></p>",
|
||||
"applicationDeadline": "2027-01-02T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2027-01-02T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-10-02T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"hiringOrgName": "Aalborg Universitet",
|
||||
"occupation": "Adjunkt",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/8ccbb9fe-0536-4a7f-a53a-63009f8f8ccd",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "96ce51c8-4aa6-4056-9a55-7242aa140a05",
|
||||
"jobAdUrl": "https://www.stillinger.aau.dk/videnskabelige-stillinger/vis-stilling/vacancyId/967442",
|
||||
"hasLogo": true,
|
||||
"workPlaceAddress": " ",
|
||||
"cvr": "29102384",
|
||||
"title": "Assistant professor or Assistant professor Tenure Track, Department of Computer Science, Copenhagen Section",
|
||||
"description": "<p><strong>Assistant professor or Assistant professor Tenure Track, Department of Computer Science, Copenhagen Section</strong></p>\n<p>Department of Computer Science, Aalborg University is hiring Assistant professors or Assistant professors Tenure Track starting <strong>February 1, 2027</strong>. The Assistant professor position is a 3-year fixed term full-time position, and the tenure track position, is a structured career pathway with clearly defined criteria for progression to a permanent position upon successful evaluation.</p>\n<p>One position will be affiliated with the research group <a href=\"https://www.cs.aau.dk/research/research-groups/probabilistic-and-symbolic-ai-psai\">Probabilistic and Symbolic AI</a> in the Copenhagen section.</p>",
|
||||
"applicationDeadline": "2026-11-01T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2026-11-01T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-09-30T00:00:00+02:00"
|
||||
}
|
||||
],
|
||||
"totalJobAdCount": 5860,
|
||||
"searchString": ""
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
"""The Jobnet reader (`/bff/FindJob/Search`): 100 ads a page, page numbers
|
||||
from 1, the header `x-csrf: 1`. No network: `get` is a stub."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from plugins import readers # noqa: E402
|
||||
from plugins.readers import Ask, jobnet # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "search"
|
||||
PLACES = (FIXTURES / "jobnet-places.json").read_bytes()
|
||||
OTHER = (FIXTURES / "jobnet.json").read_bytes()
|
||||
END = (FIXTURES / "jobnet-end.json").read_bytes()
|
||||
|
||||
|
||||
def _stock(total: int | None, stock: int, asked: list[tuple[str, dict[str, str]]]) -> Any:
|
||||
def get(url: str, **kwargs: Any) -> bytes:
|
||||
asked.append((url, kwargs.get("headers") or {}))
|
||||
query = parse_qs(urlsplit(url).query)
|
||||
start = (int(query["pageNumber"][0]) - 1) * int(query["resultsPerPage"][0])
|
||||
size = int(query["resultsPerPage"][0])
|
||||
body: dict[str, Any] = {"jobAds": [
|
||||
{"jobAdId": str(n), "title": f"Role {n}", "jobAdUrl": ""}
|
||||
for n in range(start, min(start + size, stock))]}
|
||||
if total is not None:
|
||||
body["totalJobAdCount"] = total
|
||||
return json.dumps(body).encode()
|
||||
return get
|
||||
|
||||
|
||||
def _rows(body: bytes) -> list[dict[str, Any]]:
|
||||
decoded, *_ = jobnet.page(lambda url, **kw: body, "", None, Ask())
|
||||
return jobnet.rows(decoded, "")
|
||||
|
||||
|
||||
def test_it_is_a_search_reader_naming_the_redirect_and_the_header() -> None:
|
||||
assert readers.PROVIDERS["jobnet"] is jobnet
|
||||
reads = jobnet.READS
|
||||
assert (reads.scope, reads.page_size, reads.ceiling, reads.places, reads.complete) == (
|
||||
"search", 100, 10000, "one", "stated")
|
||||
assert "redirects" in reads.robots and "x-csrf" in reads.robots and "2026-10-03" in reads.robots
|
||||
assert jobnet.PARAMS == {"q": "query", "region": "place"}
|
||||
assert jobnet.allowed("")("jobnet.dk") and not jobnet.allowed("")("example.com")
|
||||
|
||||
|
||||
def test_it_reads_title_company_date_and_the_full_text() -> None:
|
||||
first, taxi, _metal, roskilde, *_ = _rows(PLACES)
|
||||
assert first["source_id"].startswith("5e6a1854-")
|
||||
assert first["title"] == "kok til asiatisk takeaway"
|
||||
assert first["company"] == "Mywok ApS"
|
||||
assert first["country"] == "DK"
|
||||
assert first["posted"].date().isoformat() == "2026-10-03"
|
||||
assert first["description"] and "<" not in first["description"]
|
||||
assert taxi["description"].startswith("## ") # a heading stays one
|
||||
assert roskilde["description"].count("• ") == 9 # a list keeps its bullets
|
||||
assert "remote" not in first and "teaser" not in first
|
||||
|
||||
|
||||
def test_an_ad_without_its_own_link_opens_jobnets_page_for_it() -> None:
|
||||
first, _taxi, _metal, roskilde, *_ = _rows(PLACES)
|
||||
assert first["url"] == f"https://jobnet.dk/find-job/{first['source_id']}"
|
||||
assert roskilde["url"].startswith("https://candidate.hr-manager.net/")
|
||||
|
||||
|
||||
def test_the_place_is_the_municipality_else_the_postal_district_else_none() -> None:
|
||||
first, taxi, metal, *_ = _rows(PLACES)
|
||||
assert first["places"] == [{"text": "Frederiksberg", "remote": None}]
|
||||
assert taxi["places"] == [{"text": "Gladsaxe", "remote": None}] # not Søborg
|
||||
assert (metal["places"], metal["location"]) == (
|
||||
[{"text": "Rødovre", "remote": None}], "Rødovre")
|
||||
german, aau = _rows(OTHER)
|
||||
assert (german["places"], aau["places"], aau["location"]) == ([], [], "")
|
||||
|
||||
|
||||
def test_the_country_is_danish_unless_the_ad_names_another() -> None:
|
||||
german, aau = _rows(OTHER)
|
||||
assert (german["country"], aau["country"]) == ("DE", "DK")
|
||||
assert german["url"].startswith("https://germantechjobs.de/")
|
||||
assert jobnet._country("") == "DK"
|
||||
assert jobnet._country("Norge") == "NO" and jobnet._country("Sweden") == "SE"
|
||||
assert jobnet._country("Atlantis") is None
|
||||
|
||||
|
||||
def test_the_deadline_is_kept_in_raw_and_1900_means_none() -> None:
|
||||
german, _aau = _rows(OTHER)
|
||||
assert german["applicationDeadline"] == "2027-01-02T00:00:00+01:00"
|
||||
ad = json.loads(OTHER)["jobAds"][0] | {"applicationDeadline": "1900-01-01T00:00:00+01:00"}
|
||||
[row] = jobnet.rows({"jobAds": [ad]}, "")
|
||||
assert "applicationDeadline" not in row
|
||||
|
||||
|
||||
def test_an_ad_without_an_id_or_a_title_is_skipped() -> None:
|
||||
ads = json.loads(OTHER)["jobAds"]
|
||||
assert jobnet.rows({"jobAds": [ads[0] | {"title": " "}, ads[1] | {"jobAdId": ""}]}, "") == []
|
||||
|
||||
|
||||
def test_it_sends_the_header_the_region_and_the_page_number() -> None:
|
||||
asked: list[tuple[str, dict[str, str]]] = []
|
||||
get = _stock(250, 250, asked)
|
||||
jobnet.page(get, "", None, Ask(params={"q": "data science", "region": "Midtjylland"}))
|
||||
jobnet.page(get, "", 2, Ask(params={"q": "data", "region": ""}))
|
||||
jobnet.page(get, "", None, Ask(query="head of AI", places=("Nordjylland",)))
|
||||
assert all(headers == {"x-csrf": "1"} for _url, headers in asked)
|
||||
assert parse_qs(urlsplit(asked[0][0]).query) == {
|
||||
"searchString": ["data science"], "orderType": ["PublicationDate"],
|
||||
"resultsPerPage": ["100"], "pageNumber": ["1"], "regions": ["Midtjylland"]}
|
||||
assert "regions" not in urlsplit(asked[1][0]).query and "pageNumber=2" in asked[1][0]
|
||||
assert "searchString=head+of+AI" in asked[2][0] and "regions=Nordjylland" in asked[2][0]
|
||||
assert urlsplit(asked[0][0]).netloc == "jobnet.dk"
|
||||
assert urlsplit(asked[0][0]).path == "/bff/FindJob/Search"
|
||||
|
||||
|
||||
def test_it_states_the_total_and_counts_the_ads_it_listed() -> None:
|
||||
_decoded, found, total, cursor = jobnet.page(
|
||||
lambda url, **kw: PLACES, "", None, Ask())
|
||||
assert total == 57 and len(found) == 6 and cursor is None # a short page ends it
|
||||
assert found[0]["id"] == _rows(PLACES)[0]["source_id"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("cursor", "stock", "after"), [
|
||||
(None, 250, 2), (2, 250, 3), (3, 250, None), # a short page is the end
|
||||
(99, 20000, 100), (100, 20000, None), # the ceiling: page 100 is the last
|
||||
])
|
||||
def test_it_pages_by_number_up_to_the_ceiling(
|
||||
cursor: int | None, stock: int, after: int | None) -> None:
|
||||
_decoded, _found, _total, nxt = jobnet.page(
|
||||
_stock(None, stock, []), "", cursor, Ask(params={"q": "x"}))
|
||||
assert nxt == after
|
||||
|
||||
|
||||
def test_the_page_past_the_last_is_empty_and_ends_the_read() -> None:
|
||||
decoded, found, total, nxt = jobnet.page(lambda url, **kw: END, "", 101, Ask())
|
||||
assert (found, total, nxt, jobnet.rows(decoded, "")) == ([], 20684, None, [])
|
||||
|
||||
|
||||
def test_an_answer_that_is_no_search_result_raises() -> None:
|
||||
with pytest.raises(ValueError, match="jobAds"):
|
||||
jobnet.page(lambda url, **kw: b'{"message": "denied"}', "", None, Ask())
|
||||
|
||||
|
||||
def test_it_refuses_an_unknown_region() -> None:
|
||||
with pytest.raises(ValueError, match="region"):
|
||||
jobnet.page(lambda url, **kw: b"{}", "", None,
|
||||
Ask(params={"q": "x", "region": "Skane"}))
|
||||
|
||||
|
||||
def test_the_regions_are_the_five_with_their_danish_labels() -> None:
|
||||
assert list(jobnet.REGIONS) == [
|
||||
"HovedstadenOgBornholm", "Midtjylland", "Syddanmark", "OevrigeSjaelland", "Nordjylland"]
|
||||
assert jobnet.REGIONS["OevrigeSjaelland"] == "Øvrige Sjælland"
|
||||
|
||||
|
||||
def test_saved_params_keep_a_region_or_none() -> None:
|
||||
assert jobnet.clean_params({"q": "x", "region": " Midtjylland "}) == {
|
||||
"q": "x", "region": "Midtjylland"}
|
||||
assert jobnet.clean_params({"q": "x"}) == {"q": "x", "region": ""}
|
||||
with pytest.raises(ValueError, match="region"):
|
||||
jobnet.clean_params({"q": "x", "region": "Skane"})
|
||||
Reference in new issue
Block a user