falseok 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,218 @@
1
+ Metadata-Version: 2.4
2
+ Name: falseok
3
+ Version: 0.2.0
4
+ Summary: Catch the 200 OK that isn't: spot block pages and silently broken scraped data.
5
+ Author: Benchmarked
6
+ License: MIT
7
+ Project-URL: Homepage, https://benchmarked.website
8
+ Keywords: scraping,web-scraping,captcha,data-quality,monitoring,soft-404
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Internet :: WWW/HTTP
13
+ Classifier: Topic :: Software Development :: Testing
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Dynamic: license-file
18
+
19
+ <p align="center">
20
+ <picture>
21
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/hero-dark.svg">
22
+ <img src="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/hero-light.svg" alt="falseok: catch the 200 OK that isn't" width="880">
23
+ </picture>
24
+ </p>
25
+
26
+ **Your scraper didn't fail. It succeeded at saving a captcha.**
27
+
28
+ `falseok` tells you when a scraped page that came back `200 OK` is really a block, a login wall or an empty shell,
29
+ and when today's dataset quietly broke.
30
+
31
+ ```bash
32
+ pip install falseok
33
+ falseok page product.html --status 200
34
+ falseok data today.json --vs yesterday.json
35
+ ```
36
+
37
+ Pure Python, zero dependencies, works with whatever fetches your pages. It recognises blocks. It never tries to get
38
+ around them.
39
+
40
+ ## Twelve tools, the same saved pages
41
+
42
+ <!-- bench:start -->
43
+ <p align="center">
44
+ <picture>
45
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/bench-dark.svg">
46
+ <img src="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/bench-light.svg" alt="Twelve tools on the same 5,071 saved pages: falseok gave a wrong verdict on 2.5% of them, the next best tool on 8.2%; falseok caught 98.5% of the anti-bot blocks and 76.6% of the unusable 200 OK pages, and flagged 0.7% of the real pages" width="880">
47
+ </picture>
48
+ </p>
49
+
50
+ 5,071 pages from sites sampled automatically in 38 languages, fetched once, code frozen before any page was read or any tool was run. Every tool judged the same bytes, with the status code and the response headers. 5,067 pages got a label: 3,494 real, 588 anti-bot blocks, 646 other refusals, 339 empty. 444 of the 1,573 unusable pages came back without an error status; the table calls them "200 OK". A wrong verdict is an unusable page let through or a real page flagged, out of all 5,067.
51
+
52
+ | tool | wrong verdicts | blocks caught | unusable "200 OK" caught | real pages flagged | other refusals caught | empty pages caught | ms per page |
53
+ |---|---:|---:|---:|---:|---:|---:|---:|
54
+ | **falseok** | **2.5%** | **98.5%** | **76.6%** | 0.7% | **95.0%** | **81.4%** | 1.91 |
55
+ | *Built for the same job* | | | | | | | |
56
+ | a Rust scraper's anti-bot classifier | 15.2% | 91.5% | 45.0% | 0.1% | 14.4% | 52.2% | 1.72 |
57
+ | the blocked-page detector of a popular Python crawler | 15.3% | 91.7% | 45.3% | 0.2% | 14.1% | 52.2% | 3.19 |
58
+ | a new Python response classifier | 22.2% | 61.9% | 21.6% | 0.3% | 1.1% | 25.7% | 57.3 |
59
+ | the most used anti-bot detector, JavaScript | 23.0% | 65.6% | 5.6% | **0.0%** | 0.5% | 5.9% | 2.54 |
60
+ | a Rust challenge detector | 34.3% | 58.5% | 12.4% | 18.3% | 13.8% | 13.0% | 0.21 |
61
+ | *Rules inside scraping frameworks* | | | | | | | |
62
+ | the ban rule of the most used proxy-rotation add-on | 8.2% | 94.0% | 6.1% | **0.0%** | 89.6% | 7.1% | 0.14 |
63
+ | the blocked-request rule of a major crawling framework | 20.2% | 90.1% | 0.2% | **0.0%** | 3.3% | 0.0% | 25.5 |
64
+ | the challenge checks of the most used Cloudflare library | 31.0% | 0.0% | 0.0% | **0.0%** | 0.0% | 0.0% | 0.02 |
65
+ | *One-line checks* | | | | | | | |
66
+ | status-code check (4xx/5xx = bad) | 8.8% | 93.5% | 0.0% | **0.0%** | 89.6% | 0.0% | <0.01 |
67
+ | page-size check (under 10 KB = bad) | 13.3% | 89.1% | 56.1% | 1.1% | 34.5% | 57.2% | <0.01 |
68
+ | keyword search (captcha, blocked, access denied...) | 63.0% | 84.4% | 49.1% | 76.1% | 58.2% | 50.1% | 3.06 |
69
+
70
+ falseok gave a wrong verdict on 2.5% of the labelled pages; the next best tool, the ban rule of the most used proxy-rotation add-on, on 8.2%: **3.3 times fewer** wrong verdicts. Bold is the best value in a column. The one-line checks are the fastest because they read almost nothing: a status code, a length.
71
+
72
+ Some of these tools were built for a narrower job (only Cloudflare challenges, only status codes, only anti-bot vendors); the [benchmark](https://github.com/benchmarked-hq/falseok/blob/main/docs/benchmark.md) quotes what each one claims to catch, with 95% confidence intervals.
73
+
74
+ "Other refusals" are pages not found, server errors, login-only pages and the like. Most of them carry an error status, which is why a plain status check does well there (89.6%) and catches no empty page at all.
75
+
76
+ **Where falseok loses: real pages flagged.** It flagged 24 of 3,494 real pages (0.7%). Three tools flagged none, two more flagged a single page. Of the 24: 14 were called empty (real pages with very little text, among them a few search pages with no results), 3 were pages that are a login form, 6 were called a captcha or a challenge, and 1 was a real page its server sent with status `503`. The tools with zero false alarms judge only the status code or a few known signatures, or decline to judge many pages, and they catch 0 to 25 of the 444 unusable pages that came back without an error status; falseok caught 340.
77
+
78
+ **What it missed:** 9 of the 588 blocks, all served with status `200`.
79
+
80
+ **Speed:** about 1.3 times faster than the most used JavaScript detector, level with the Rust classifier, about 30.0 times faster than the new Python classifier. The quickest checks (the Rust challenge detector, the proxy add-on's ban rule, the Cloudflare checks, status code, page size) are faster still, because they read almost nothing or stop at the first match. Next to a download of 500 ms or more, under 2 ms is noise.
81
+ <!-- bench:end -->
82
+
83
+ ## More than a block detector
84
+
85
+ <!-- more:start -->
86
+ <p align="center">
87
+ <picture>
88
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/more-dark.svg">
89
+ <img src="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/more-light.svg" alt="More than a block detector: page not found 100% with the status, empty shells 81.4%, block markers in the response headers of 4 anti-bot services, 44 languages, 1,020 of 1,020 broken dataset days caught" width="880">
90
+ </picture>
91
+ </p>
92
+
93
+ - **Page not found:** 529 of 529 pages that came back `404` or `410` with the status given, and 408 of 529 from the page alone, when your scraper didn't keep the status.
94
+ - **Empty shells:** 276 of 339 pages that loaded a menu and a footer and nothing else.
95
+ - **Response headers:** pass them (`--headers`, or `headers=` in Python) and it reads the anti-bot service's own
96
+ block marker and names the vendor (4 services so far).
97
+ - **44 languages:** "page not found", "access denied" and the other wording sites write themselves, each phrase
98
+ taken from a page that really came back.
99
+ - **Datasets:** on four real scraped datasets, it caught **1,020 of 1,020** deliberately broken days (lost rows,
100
+ emptied or vanished fields, frozen values, type changes, duplicates, block pages saved as rows) and stayed quiet on
101
+ **200 of 200** healthy ones. A row-count alert, what most pipelines have, caught 240.
102
+
103
+ Three things we learned the hard way:
104
+
105
+ - **Status codes lie.** 444 of the 1573 unusable pages in the benchmark came back without an error status. A status check calls all of them a success.
106
+ - **Grepping for "captcha" flags 76% of real pages** (2660 of 3494). Anti-bot scripts, signup captchas and cookie
107
+ banners load on normal pages too.
108
+ - **Block pages are short. Real pages aren't.** The block pages we measured carry 0 to ~2,000 characters of visible
109
+ text. That one fact does most of the work, and it is also where falseok's few false alarms come from.
110
+ <!-- more:end -->
111
+
112
+ ## Check pages
113
+
114
+ ```bash
115
+ falseok page product.html
116
+ falseok page pages/*.html --status 200
117
+ falseok page page.html --headers headers.txt # the response headers, as `curl -D headers.txt` saves them
118
+ falseok page page.html --json
119
+ ```
120
+
121
+ <p align="center">
122
+ <picture>
123
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/verdicts-dark.svg">
124
+ <img src="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/verdicts-light.svg" alt="Every page gets one verdict: ok, not_html, challenge, captcha, rate_limited, login_wall, consent_wall, soft_block, soft_404, empty_shell, http_error" width="880">
125
+ </picture>
126
+ </p>
127
+
128
+ <details>
129
+ <summary>The verdicts as text</summary>
130
+
131
+ | verdict | what it means |
132
+ |---|---|
133
+ | `ok` | no block signal found |
134
+ | `not_html` | binary or compressed data, not a page |
135
+ | `challenge` | an anti-bot check page (the vendor is named when the HTML shows it) |
136
+ | `captcha` | a captcha in place of the content |
137
+ | `rate_limited` | "too many requests", or HTTP 429 |
138
+ | `login_wall` | you need to sign in to see this |
139
+ | `consent_wall` | a consent page in place of the content |
140
+ | `soft_block` | "access denied", "continue shopping", "something went wrong" served as 200 |
141
+ | `soft_404` | 200, but the page says it does not exist |
142
+ | `empty_shell` | empty response, a saved redirect, or a JavaScript app that never rendered |
143
+ | `http_error` | you passed `--status` 4xx/5xx and no other signal was found |
144
+
145
+ </details>
146
+
147
+ ## Check data
148
+
149
+ ```bash
150
+ falseok data today.json --vs yesterday.json
151
+ ```
152
+
153
+ <p align="center">
154
+ <picture>
155
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/terminal-dark.svg">
156
+ <img src="https://raw.githubusercontent.com/benchmarked-hq/falseok/main/assets/terminal-light.svg" alt="falseok data output: 131 rows instead of 200, 10 duplicates, a block page saved as a row, salary 62% empty" width="880">
157
+ </picture>
158
+ </p>
159
+
160
+ Reads JSON, JSON Lines, CSV and TSV, including what Excel saves on Windows and European semicolon CSVs. Finds lost
161
+ rows, fields that went empty, disappeared or froze on one value, changed types, duplicates, and block-page text that
162
+ got parsed as data. Without `--vs` it checks the file on its own.
163
+
164
+ ## In a cron job or CI
165
+
166
+ Exit code `0` = fine, `1` = something is wrong, `2` = the input could not be read.
167
+
168
+ ```bash
169
+ falseok data out/today.jsonl --vs out/last_good.jsonl && cp out/today.jsonl out/last_good.jsonl
170
+ ```
171
+
172
+ ## From Python
173
+
174
+ ```python
175
+ import falseok
176
+
177
+ r = falseok.check_page(html, status=200) # html can be text or the raw bytes you received
178
+ r = falseok.check_page(resp.content, status=resp.status_code, headers=resp.headers) # headers are optional
179
+ if not r.ok:
180
+ print(r.verdict, r.reason) # captcha robot-check-title (title: "Robot Check")
181
+
182
+ report = falseok.compare(rows_today, rows_yesterday)
183
+ for issue in report.issues:
184
+ print(issue.kind, issue.message)
185
+ ```
186
+
187
+ ## How hard we tried to break it
188
+
189
+ - **A stress suite** written to break it: random bytes, 50 MB pages, unclosed tags, every rule's wording hidden in
190
+ long real pages, Excel CSVs, JSON nested three levels down, a million rows. The first run found 107 failures. All
191
+ fixed, all still in the suite, which now holds 1,875 tests.
192
+ - **140,000 random inputs** from property-based testing. Nothing broke.
193
+ - **Three fresh sets of pages** from sites it had never seen. The first two showed misses we then fixed, so we don't
194
+ quote them as proof; the third is the benchmark above, scored with the code frozen.
195
+ - **Linux, macOS and Windows, Python 3.10 to 3.14**, on every change.
196
+
197
+ The whole story, failures included: [docs/testing.md](https://github.com/benchmarked-hq/falseok/blob/main/docs/testing.md).
198
+
199
+ ## Where the signatures come from
200
+
201
+ Every rule lives in one file, [`src/falseok/signatures.json`](https://github.com/benchmarked-hq/falseok/blob/main/src/falseok/signatures.json): a pattern, where to
202
+ look (title, visible text or raw HTML), and the category. They come from block pages our own production scrapers
203
+ received with `200 OK`, and from the live tests above. The test pages in [`tests/pages`](https://github.com/benchmarked-hq/falseok/blob/main/tests/pages) are rebuilt
204
+ from those cases with identifiers removed.
205
+
206
+ **Seen a block page falseok missed?** Send one entry in `signatures.json` and a small cleaned page in `tests/pages`.
207
+ That's the whole contribution: [docs/contributing.md](https://github.com/benchmarked-hq/falseok/blob/main/docs/contributing.md).
208
+
209
+ ## Documentation
210
+
211
+ [Benchmark](https://github.com/benchmarked-hq/falseok/blob/main/docs/benchmark.md) · [How it works](https://github.com/benchmarked-hq/falseok/blob/main/docs/how-it-works.md) · [Verdicts](https://github.com/benchmarked-hq/falseok/blob/main/docs/verdicts.md) ·
212
+ [Data checks](https://github.com/benchmarked-hq/falseok/blob/main/docs/data-checks.md) · [Signatures](https://github.com/benchmarked-hq/falseok/blob/main/docs/signatures.md) · [Testing](https://github.com/benchmarked-hq/falseok/blob/main/docs/testing.md) ·
213
+ [Known limits](https://github.com/benchmarked-hq/falseok/blob/main/docs/limits.md) · [Contributing](https://github.com/benchmarked-hq/falseok/blob/main/docs/contributing.md)
214
+
215
+ ## License
216
+
217
+ MIT. Made by [Benchmarked](https://benchmarked.website): we measure data tools against the most used alternatives on
218
+ price, speed and output.
@@ -0,0 +1,12 @@
1
+ falseok/__init__.py,sha256=NkPTQQdfbPkQuJUOD-lElQiLwZwypi15FVBNxJaugTw,375
2
+ falseok/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
3
+ falseok/cli.py,sha256=J32__rxPKBvoVQ4aZDIxnStmhC33MKLZsjrhpA_g17c,4824
4
+ falseok/data.py,sha256=FbB42m01f96NdjDUJp5877X4_NamahU9GnTskkM0YCo,14385
5
+ falseok/page.py,sha256=niV-SFQOP5tGrrKvcMJ2chKyGhMX53VrkupaXtKThXw,37728
6
+ falseok/signatures.json,sha256=2h-ZXSdIJxObLd7OLcuB0wsB6g1SlxnNEtutsHiBT8w,33777
7
+ falseok-0.2.0.dist-info/licenses/LICENSE,sha256=e7K2pJtPKQmc09LHMDGsR1_wHAaOYH85TonqR5ljM2g,1068
8
+ falseok-0.2.0.dist-info/METADATA,sha256=VpMnlAYe38CDq4OAEse5PhiTtVpl3yTxvW92z7Ho9Sk,13515
9
+ falseok-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
10
+ falseok-0.2.0.dist-info/entry_points.txt,sha256=MT_eH3Xl48O4KdXT-sCwhhAVA-n_UaDC6tOkXT2J12Y,45
11
+ falseok-0.2.0.dist-info/top_level.txt,sha256=_OTkX0TAY53JGHnG3mTc5fD9dgfnP8Wl-Xh6jXO_z6Q,8
12
+ falseok-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ falseok = falseok.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Benchmarked
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ falseok