mirror of
https://github.com/webrecorder/browsertrix-crawler.git
synced 2025-10-19 14:33:17 +00:00
Implemented option for FullPage screenshot after the behaviours have run (#656)
- new `fullPageFinal` screenshot option, which will take a full page screenshot after behaviors are run, or before moving onto next page if behaviors are skipped. Related to #486 --------- Co-authored-by: Tessa Walsh <tessa@bitarchivist.net> Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
This commit is contained in:
parent
214eb6ca8f
commit
07e5ceb4c2
3 changed files with 30 additions and 3 deletions
|
@ -1031,6 +1031,23 @@ self.__bx_behaviors.selectMainBehavior();
|
|||
if (textextract && this.params.text.includes("final-to-warc")) {
|
||||
await textextract.extractAndStoreText("textFinal", true, true);
|
||||
}
|
||||
|
||||
if (
|
||||
this.params.screenshot &&
|
||||
this.screenshotWriter &&
|
||||
this.params.screenshot.includes("fullPageFinal")
|
||||
) {
|
||||
await page.evaluate(() => {
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
const screenshots = new Screenshots({
|
||||
browser: this.browser,
|
||||
page,
|
||||
url,
|
||||
writer: this.screenshotWriter,
|
||||
});
|
||||
await screenshots.takeFullPageFinal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -390,7 +390,7 @@ class ArgParser {
|
|||
|
||||
screenshot: {
|
||||
describe:
|
||||
"Screenshot options for crawler, can include: view, thumbnail, fullPage",
|
||||
"Screenshot options for crawler, can include: view, thumbnail, fullPage, fullPageFinal",
|
||||
type: "array",
|
||||
default: [],
|
||||
choices: Array.from(Object.keys(screenshotTypes)),
|
||||
|
|
|
@ -15,7 +15,7 @@ type ScreenShotDesc = {
|
|||
encoding: "binary";
|
||||
};
|
||||
|
||||
type ScreeshotType = "view" | "thumbnail" | "fullPage";
|
||||
type ScreeshotType = "view" | "thumbnail" | "fullPage" | "fullPageFinal";
|
||||
|
||||
export const screenshotTypes: Record<string, ScreenShotDesc> = {
|
||||
view: {
|
||||
|
@ -36,6 +36,12 @@ export const screenshotTypes: Record<string, ScreenShotDesc> = {
|
|||
fullPage: true,
|
||||
encoding: "binary",
|
||||
},
|
||||
fullPageFinal: {
|
||||
type: "png",
|
||||
omitBackground: true,
|
||||
fullPage: true,
|
||||
encoding: "binary",
|
||||
},
|
||||
};
|
||||
|
||||
export type ScreenshotOpts = {
|
||||
|
@ -63,7 +69,7 @@ export class Screenshots {
|
|||
state: PageState | null = null,
|
||||
) {
|
||||
try {
|
||||
if (screenshotType !== "fullPage") {
|
||||
if (screenshotType !== "fullPage" && screenshotType !== "fullPageFinal") {
|
||||
await this.browser.setViewport(this.page, {
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
|
@ -105,6 +111,10 @@ export class Screenshots {
|
|||
await this.take("fullPage");
|
||||
}
|
||||
|
||||
async takeFullPageFinal() {
|
||||
await this.take("fullPageFinal");
|
||||
}
|
||||
|
||||
async takeThumbnail() {
|
||||
const screenshotType = "thumbnail";
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue