Repository navigation
Conversation
Regenerated from a browser built from its page-classify branch. Like extract's schema, classify's questions is a JSON string on the wire, so the generator now types both as `str | dict | list` from one table. The tests answer through a mock TypeSafe server (TYPESAFE_BASE_URL) and skip on a binary without the tool, such as the nightly CI builds against until classify ships.
judge() asks the browser for all its presets in one classify call, through the empty questions object, and answers with bools at a threshold: is_blocked, is_login_wall, is_paywall and the rest, plus `ok` when none fired and `reason` for the strongest that did. `scores` keeps the probabilities, since Jev is not deterministic and a borderline score can land either side. More than one can be true at once (a consent banner on a login wall, a bot block that is also an error page), so the verdict is a set of flags rather than one class. The browser owns the preset list: one added later still shows up in `scores` and as an attribute without a release here. Regenerated from a browser built from its page-classify branch.
classify_pages.py asks each page what it is (presets, a yes/no question, a choice, a category list scoped by selector), then gates the same URLs with judge(). Until a release ships judge(), its inline metadata installs this checkout rather than the PyPI package.
The example output is refreshed from a run against that browser: the empty Wikipedia search now scores 0.99 instead of a borderline 0.56.
Regenerated from a browser that accepts `{question, levels}`, and the mock
TypeSafe server now answers score questions.
The triage table gains a value column from a score question ("How much
useful content would a scraper get from this page?" on none/little/plenty),
so the example covers all three of Jev's question types. The README shows
it, and why a score lands between levels.
G2's DataDome CAPTCHA now reads as is_captcha, where the markdown state made it an error page.
Each page loads once: judge() skips walls, CAPTCHAs and empty searches, and the rest get one classify call with a yes/no, a choice and a score.
`page.judge(questions=...)` sends them with `presets: true`, so one
TypeSafe call answers the walls and the caller's questions; the answers
land in `verdict.answers`. Without questions it sends `{}` as before, so it
still works against a browser without the option.
The example asks its questions through judge() instead of a second classify(), and prints each page's load and Jev time.
triage_crawl.py judges 29 real pages with six browsers at once. The verdict drives the crawler: accept a cookie wall and look again, back off when the page says we are going too fast (our own question, asked in the same call), wait for a page still loading, or skip it and say why. It ends with the counts and Jev's median and p90 call time.
Each crawler drives its own session, and the browser now loads their pages in parallel, so the example no longer starts one browser per crawler.
visit() reads top to bottom: back off, accept cookies, wait. A semaphore caps the pages in flight instead of a queue and worker loop.
A verdict the crawler acts on gets its own retry line saying what it does, so a cookie wall shows before the page behind it and a rate-limited page shows once per try. The cookie click uses found[0].click().
Indeed now answers with a 403 bot block on most loads, so the crawl never reached its cookie wall. El Mundo and 20 Minutes serve one on every load, and clicking its accept button clears it.
Of the 1,781 pages that answered 4xx or 5xx in the classifier's crawl, Jev found none worth reading: every one fired a check, and the seven that fired none on both votes were blocks it scored near 0.6. Asking it is a round trip for an answer the status already gave. The session keeps the status the last navigation or action reported, and judge() returns from it before calling classify: 401 names a login wall, 402 a paywall, 403 and 429 a block, anything else an error page. Scores and answers stay None, so a caller can tell a verdict the model gave from one it did not. A 2xx page still goes to Jev, since bot blocks often arrive as 200.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wraps the browser's
classifytool, which is now in nightly.Session.classify(questions, ...): the generated method for the tool, with sync and async variants.Session.judge(): asks every classify preset in one call and returns aPageVerdict. You can add your own questions to the same call. A 4xx or 5xx page is judged by its status without asking Jev.examples/classify_pages.pyandexamples/triage_crawl.py, a parallel crawl that acts on each verdict, plus their README section._methods.pyis regenerated against nightly. That run also picks up the tools added since main's last regeneration:acceptCookies,callPageTool,download,login,pageTools,runandmarkdown(alternate=...).The examples no longer point
uvat this checkout. They need alightpandarelease that includesjudge()before they work from PyPI.Replaces the
page-classifybranch, rebased onto main.