Decode HTML entities in freehire titles and companies, and separate the region ids in the searches help
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a9c387c130
commit
10dec33dce
3 files changed
+12
-4
No files matched your search
+2
-2
@@ -152,8 +152,8 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
search_add.add_argument("--where", default="", help="adzuna place, e.g. Berlin")
|
||||
search_add.add_argument("--region", default="",
|
||||
help="platsbanken län id: CaRE_1nn_cSU is Skåne, empty all of "
|
||||
"Sweden" + _ids("jobnet", "REGIONS", "; jobnet region")
|
||||
+ _ids("jobbank", "REGIONS", "; jobbank amt"))
|
||||
"Sweden" + _ids("jobnet", "REGIONS", "; jobnet region: ")
|
||||
+ _ids("jobbank", "REGIONS", "; jobbank amt: "))
|
||||
search_add.add_argument("--remote", default="",
|
||||
help="freehire work mode" + _ids("freehire", "MODES", ": ")
|
||||
+ _ids("jobbank", "REMOTE", "; jobbank remote work: ")
|
||||
|
||||
@@ -27,6 +27,7 @@ table of the host's words in `app/prep/hosts/freehire.py`.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
@@ -166,7 +167,7 @@ def _pay(enrichment: dict[str, Any]) -> dict[str, Any]:
|
||||
def rows(decoded: Any, slug: str) -> list[Row]:
|
||||
out: list[Row] = []
|
||||
for hit in decoded.get("data") or []:
|
||||
title = " ".join(str(hit.get("title") or "").split())
|
||||
title = " ".join(html.unescape(str(hit.get("title") or "")).split())
|
||||
source_id = str(hit.get("public_slug") or "").strip()
|
||||
url = _url(str(hit.get("url") or ""))
|
||||
if not title or not source_id or not is_web_url(url):
|
||||
@@ -177,7 +178,7 @@ def rows(decoded: Any, slug: str) -> list[Row]:
|
||||
out.append({
|
||||
"source_id": source_id,
|
||||
"title": title,
|
||||
"company": str(hit.get("company") or "").strip(),
|
||||
"company": html.unescape(str(hit.get("company") or "")).strip(),
|
||||
"url": url,
|
||||
"places": places,
|
||||
"location": places[0]["text"] if places else "",
|
||||
|
||||
@@ -129,6 +129,13 @@ def test_it_refuses_a_hit_without_a_title_an_id_or_a_web_link() -> None:
|
||||
assert found[0]["url"] == "https://x.example/d" and found[0]["places"] == []
|
||||
|
||||
|
||||
def test_a_title_and_a_company_have_their_entities_decoded() -> None:
|
||||
hit = {"public_slug": "a", "title": "IoT Certification & License Manager",
|
||||
"company": "Ben & Jerry's", "url": "https://x.example/a"}
|
||||
row = freehire.rows({"data": [hit]}, "")[0]
|
||||
assert (row["title"], row["company"]) == ("IoT Certification & License Manager", "Ben & Jerry's")
|
||||
|
||||
|
||||
def test_it_asks_for_countries_work_mode_and_the_text_in_html() -> None:
|
||||
asked: list[str] = []
|
||||
freehire.page(_stock(250, 250, asked), "", None,
|
||||
|
||||
Reference in new issue
Block a user