mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-25 09:06:02 +03:00
[GH-ISSUE #51] Add ability to run JS scripts during archiving with Playwright/Puppeteer #1544
Labels
No labels
expected: maybe someday
expected: next release
expected: release after next
expected: unlikely unless contributed
good first ticket
help wanted
pull-request
scope: all users
scope: windows users
size: easy
size: hard
size: medium
size: medium
status: backlog
status: blocked
status: done
status: idea-phase
status: needs followup
status: wip
status: wontfix
touches: API/CLI/Spec
touches: configuration
touches: data/schema/architecture
touches: dependencies/packaging
touches: docs
touches: js
touches: views/replayers/html/css
why: correctness
why: functionality
why: performance
why: security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ArchiveBox#1544
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pirate on GitHub (Nov 2, 2017).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/51
https://github.com/GoogleChrome/puppeteer is fantastic for scripting actions on pages before making a screenshot or PDF.
I could add support for custom puppeteer scripts for certain urls that need a user action to be performed before archiving (e.g. logging in or closing a welcome message popup).
Puppeteer code looks like this:
@pirate commented on GitHub (Sep 12, 2018):
Would go well with: https://github.com/checkly/puppeteer-recorder
@FiloSottile commented on GitHub (Dec 1, 2018):
archive.is has a nice set of scripts that do things like expanding all Reddit threads or scrolling through Twitter timelines before taking a snapshot. This is the kind of thing I've seen develop a nice community around with youtube-dl.
@pirate commented on GitHub (Mar 15, 2019):
The beginnings of this will start to be implemented with our move from
chromium-browsertoplaywright: #177, then these will be possible:pyppeteer@n0ncetonic commented on GitHub (Mar 23, 2019):
I have experience with coding Puppeteer scripts and I'm willing to start either implementing fixes for #175 #80 #130 as independent code samples in preparation for
pyppeteeror to start a branch that just replicates current functionality but withpyppeteerdepending on whether or not you've started a private branch or prefer to implement it yourself@pirate commented on GitHub (Mar 23, 2019):
Sweet, the super-rough planned design is for ArchiveBox to run user-provided scripts like this:
The final implementation will be more fully-featured than this of course. S context and any output returned gets saved as an ArchiveResult entry like any other extractor.
@n0ncetonic commented on GitHub (Mar 23, 2019):
Alright cool, I will start working on getting that implemented on my fork.
Planning to do this in 3 phases across two milestones which I think align well with the current roadmap.
Phase I. import
pyppeteerand replace all currentchromium-browsercalls withpyppeteerequivalents.Milestone I. ArchiveBox migrated to
pyppeteerPhase II. Implement minimalist scripting support allowing users to extend browser-based modules using javascript.
Milestone II. Codebase aligned with Roadmap's Long Term Change to allow user-defined scripting of the browser.
Phase III. Bootstrap collection of browser scripts by creating and including
autoscroll_screenshot.js- screenshot capturing of the entire page by autoscrolling #80anti_detection.js- bypasses detection/blocking of headless browser via selective overwriting of page-wide getter properties this is something I have working for a personal project that leveraged Puppeteercookie_accept.js- generic enumeration and dismissal of GDPR/subscription/cookie popups #175Note: As my primary aim will be to make progress on the Roadmap #130 will not be a requisite for Phase III completion. Once Phase III is complete and merged into master a separate Pull Request will address extending WARC generation.
We'll go to next steps (like mimicking archive_methods.py loading of scripts) after Phase III provides a working, basic scripting subsystem
@pirate commented on GitHub (Mar 23, 2019):
If possible, work on the Phase III scripts first. Those would be most helpful to me, as I've already started work on the phase I and II steps you outlined above over the last few months.
You can test your scripts using the pyppeteer demo code from their README, and I'll make sure the ArchiveBox API is compatible to work with them.
@pirate commented on GitHub (Apr 17, 2019):
I found some huge repositories of Seleneium/Puppeteer scripts for dismissing modals and logging in to lots of sites. These are going to be super useful:
@pirate commented on GitHub (Jan 22, 2021):
Whoops closed/reopened by accident. A quick update for those following this issue, we have a number of blocking tasks before we're going to get around to this:
Lots of work has been done so far to get us to step 1, but we're still at the foothills of what will be required before this feature is ready for prime-time. It's still high up on our list of desired features but don't expect it anytime soon.
@UmutAlihan commented on GitHub (Jun 7, 2021):
Looking very forward for these feautures to be implemented. Since Cloudflare now effectively blocks content crawling for many many adopting sites (such as Medium), functionality of Archivebox has a risk to be limited only to a sites which are not yet utilizing Cloudflare's bot detection systems.
(p.s.: Many sites are transitioning to Cloudflare's or similar services. There it is currently very likely to crawl an empty/failing archive like below example.)
@GlassedSilver commented on GitHub (Jun 7, 2021):
+1 to that.
Really, REALLY annoying to see Cloudflare being so overly aggressive.
Like sure, you can be hammering down on me if I try to pull pages from sites protected by your network in the hundreds per minute, fine. I get that.
But to blatantly block me only because JS execution doesn't verify my humanness? Sketchy at best!
Edit: btw, I'd strip that IP address from that screenshot of yours if I were you, unless it's dynamic and you're due for a new one soon. ;)
At the very least however it allows someone to possibly (roughly) geolocate you.
@pirate commented on GitHub (Dec 8, 2021):
I've started mocking up what a playwright-based pluginized refactor would look like for ArchiveBox, and I think it's pretty elegant so far! This is still a ways away, but I'm starting to crystalize what I want the plugin-style interface to be between the browser and the extractors.
Please note almost all the classes are stateless namespaces, but I still need to figure out a more elegant composition solution than all this inheritance madness.
@pellaeon commented on GitHub (Jan 8, 2022):
@pirate Do you have the playwright-based refactor in a public branch? I'd love to contribute if possible. :-)
@pirate commented on GitHub (Jan 8, 2022):
Not yet but soon! It's just in a gist right now. Will publish it once I've moved >50% of the old codebase into the new structure. I'm traveling in Mexico right now with limited work time but will keep everyone posted as it progresses!
The new design is quite exciting, I'm able to add new features as plugins with <10min of boilerplate work per feature.
https://gist.github.com/pirate/7193ab54557b051aa1e3a83191b69793
@pirate commented on GitHub (Nov 18, 2022):
Useful scripts for testing and evading archivebox-bot detection blocking with playwright/puppeteer in the future:
I'm also leaning towards implementing this using Conifer/Rhizome's well-defined spec for scripted archiving behaviors here: https://github.com/webrecorder/browsertrix-behaviors/blob/main/docs/TUTORIAL.md
Their behaviors framework is also open-source, so if we are compatible with their behaviors our communities can share behavior JS scripts and help grow the capabilities of both tools simultaneously 🎉
@pirate commented on GitHub (Apr 12, 2023):
Chrome now supports a new framework-agnostic JSON user flow export from the DevTools recording pane. I'd like to use this format if possible instead of playwright/puppeteer directly.
Waiting for a response to see if playwright will implement replay support for it. If so browsertrix-crawler will get support soon after, and I'm likely to just build on top of browsertrix crawler.
Related:
Otherwise we could also add a custom recorder format for ArchiveBox to the archivebox-extension so that export scripts can be generated directly in our own format (but I prefer the JSON approach above instead^):
Part of why this feature is taking so long is that I think all of the solutions for automating JS browser scripting right now are extremely high-maintenance/brittle, and I've been waiting for the ecosystem to mature so as not to overload limited time to work on ArchiveBox by adding a new brittle stack of things I have to maintain.
@pirate commented on GitHub (Mar 21, 2024):
I've been doing some work for paying ArchiveBox consulting clients to implement advanced puppeteer-based archiving. Here's an overview of what I'm running for them (all of these are implemented and working well right now), with more otw:
My clients (all still non-profits) pay for my time needed to learn about and implement these features, so getting it working for their immediate needs is my priority, but the plan is to integrate these new features back into the main open-source ArchiveBox codebase so everyone can benefit!
@a10kiloham commented on GitHub (May 15, 2024):
For what it's worth this functionality is quite similar to how ChangeDetection works.
https://github.com/dgtlmoon/changedetection.io/tree/master/changedetectionio/content_fetchers
It's very useful to just plug in an additional service into the docker-compose for browserless.io and then pass the websocket URL to the app and get a full browser experience totally headlessly on Ubuntu.
@pirate commented on GitHub (Dec 29, 2025):
this is now implemented on
dev, thearchivebox/plugins/chromeplugin sets up a persistent chrome tab for the snapshot and the other plugins use it for their archiving, it's easy to add JS scripts using the new hook system inarchivebox/hooks.py. for an example seearchivebox/plugins/infiniscroll