-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for saving requests to HAR file #146
Comments
https://playwright.dev/python/docs/release-notes#version-123 added this in June 2022 https://github.com/microsoft/playwright-python/releases/tag/v1.23.0 context = browser.new_context(record_har_path="github.har.zip")
# ... do stuff ...
context.close() |
Got a prototype working! I had to edit the |
--save-har=my.har
option to save requests to HAR file
I built this as a separate command: shot-scraper har https://datasette.io/ That will save it to |
|
Is there an argument for adding this as an option to other commands such as |
This option actually has no effect: shot-scraper har https://datasette.io/ --javascript 'document.title="mess with the DOM first"' Because the HAR has already been recorded by the time the JavaScript executes. |
Having |
Got Claude to write me a very neat pytest fixture for running a localhost web server: https://gist.github.com/simonw/360b520fdb82d48c669db575cf74b9f4 |
Blogged about this here: https://simonwillison.net/2025/Feb/13/shot-scraper/ |
Playwright has support for HAR files, which saves all network requests during a session to a custom file format.
The API is awkward but we can use
route_from_har
. We'll need to addupdate=True
to save requests to the file, instead of "serveing" them.There's a few more options to:
update_content
:"embed"|"attach"
. Maybe--har-content=embed
?update_mode
:"full"|"minimal"
. Maybe--har-mode=full
?The text was updated successfully, but these errors were encountered: