Skip to content

Commit 86e222f

Browse files
committed
fix(ingest): identify enrich scrapes as the TechEngine bot
make_client() sent a full Chrome header set because cpubenchmark.net, notebookcheck and technical.city refuse the bare ingest UA. Every enrich source shares that client, so the weekly refresh was getting past those sites' bot blocking by posing as a browser. Send the TechEngine-Ingest user agent instead; a site that refuses it now fails and the run skips it with a warning, as weekly-refresh already handles per-source failures. Refs #99
1 parent 03fef81 commit 86e222f

2 files changed

Lines changed: 9 additions & 23 deletions

File tree

‎app/ingest/sources/passmark.py‎

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,8 @@
2626
LOOKUP = "https://www.cpubenchmark.net/cpu_lookup.php"
2727
USER_AGENT = "TechEngine-Ingest/0.1 (+https://github.com/GetTechAPI/TechEngine)"
2828

29-
# cpubenchmark.net / notebookcheck / technical.city return 403 (or hang) for the
30-
# bare ingest UA — they bot-gate on a browser-shaped header set. We still rate-
31-
# limit via --sleep and fetch per-chip with attribution (no bulk harvest).
32-
BROWSER_HEADERS = {
33-
"User-Agent": (
34-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
35-
"(KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
36-
),
37-
"Accept": (
38-
"text/html,application/xhtml+xml,application/xml;q=0.9,"
39-
"image/avif,image/webp,*/*;q=0.8"
40-
),
41-
"Accept-Language": "en-US,en;q=0.9",
42-
"Sec-Ch-Ua": '"Chromium";v="124", "Google Chrome";v="124"',
43-
"Sec-Ch-Ua-Mobile": "?0",
44-
"Sec-Ch-Ua-Platform": '"Windows"',
45-
"Sec-Fetch-Dest": "document",
46-
"Sec-Fetch-Mode": "navigate",
47-
"Sec-Fetch-Site": "none",
48-
"Sec-Fetch-User": "?1",
49-
"Upgrade-Insecure-Requests": "1",
50-
}
29+
# Every enrich source identifies itself as this bot. A site that refuses it is
30+
# telling us not to scrape it, so its fetch fails and the run skips that source.
5131

5232
_ID_RE = re.compile(r"[?&]id=(\d+)")
5333

@@ -204,5 +184,5 @@ def fetch_scores(
204184

205185
def make_client(*, timeout: float = 30.0) -> httpx.Client:
206186
return httpx.Client(
207-
headers=BROWSER_HEADERS, timeout=timeout, follow_redirects=True
187+
headers={"User-Agent": USER_AGENT}, timeout=timeout, follow_redirects=True
208188
)

‎tests/unit/test_passmark_enrich.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
)
1616

1717

18+
def test_client_identifies_as_the_ingest_bot() -> None:
19+
with passmark.make_client() as client:
20+
assert client.headers["User-Agent"] == passmark.USER_AGENT
21+
assert "Sec-Fetch-Mode" not in client.headers
22+
23+
1824
def test_normalize_strips_clock_and_graphics_tails() -> None:
1925
assert normalize_name("AMD Ryzen 7 5800X @ 3.80GHz") == normalize_name(
2026
"AMD Ryzen 7 5800X"

0 commit comments

Comments
 (0)