Document robots.txt support, and let run_script pass browser flags - #11
Merged
Merged
Conversation
The browser has had --obey-robots since before these bindings existed, and nothing here mentioned it, so nobody using the package would find it. It is now a README section and appears in the pdoc reference, on the landing page and on each class that takes args=. The section spends most of its length on the part that surprises people: the rule applies to every request, not just the page you asked for. Sites commonly disallow the directory their own assets live in, so a permitted page can load with its scripts blocked and render blank. That is robots.txt working, and without saying so the obvious conclusion is that the flag is broken. run_script was the one entry point that could not enable it, taking no flags at all; it and run_script_async now accept args= like everything else. Not added: a named obey_robots= parameter. Every other browser flag goes through args=, and promoting one creates a second way to say the same thing plus a conflict to resolve when both are passed.
Unrelated to the robots change, but the committed file was stale: the browser gained regex matching for findElement's name argument and the regenerated docstring never landed here. CI regenerates against nightly and fails when this file drifts, so it would have failed on the next push regardless.
Two of the four classes that paragraph points at are driven through Playwright or Selenium, where a blocked request surfaces as that client's navigation error, never as a ToolError. Say what happens instead of naming one exception the reader may never see. Also rename the test fixture, which never visits anything: the flag is rejected before the script runs.
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.
The browser has had
--obey-robotssince before these bindings existed, andnothing here mentioned it, so nobody using the package would find it. It is now
a README section and appears in the pdoc reference, on the landing page and on
each class that takes
args=.Most of that section is spent on the part that surprises people, verified
against a live site rather than assumed: the rule applies to every request,
not just the page you asked for. Sites commonly disallow the directory their own
assets live in, so a permitted page can load with its scripts blocked and render
blank. On
neurips.cc— the siteexamples/neurips_topics.pyreads — the pageis allowed but its JavaScript sits under
/static, which their robots.txtdisallows, so the paper list never appears. That is robots.txt working, and
without saying so the obvious conclusion is that the flag is broken.
run_scriptwas the one entry point that could not enable it, taking no flags atall. It and
run_script_asyncnow acceptargs=like everything else, with atest that passes a flag the binary rejects, so it needs no network.
Not added: a named
obey_robots=parameter. Every other browser flag goesthrough
args=, and promoting one creates a second way to say the same thingplus a conflict to resolve when both are passed.
The second commit is unrelated and can be dropped if you would rather it landed
separately: rebuilding the pdoc docs regenerates
_methods.py, which was stale.The browser gained regex matching for
findElement's name argument and theregenerated docstring never landed here. That change is in the browser's main,
so nightly has it and CI would have failed on the next push regardless.