Skip to content

Commit

Permalink
Disable behaviors entirely if --behaviors array is empty (#672)
Browse files Browse the repository at this point in the history
Fixes #651
  • Loading branch information
tw4l authored Aug 27, 2024
1 parent c61a03d commit 39c8f48
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/docs/user-guide/behaviors.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ See [Browsertrix Behaviors](https://github.com/webrecorder/browsertrix-behaviors

Browsertrix Crawler includes a `--pageExtraDelay`/`--delay` option, which can be used to have the crawler sleep for a configurable number of seconds after behaviors before moving on to the next page.

To disable behaviors for a crawl, use `--behaviors ""`.

## Additional Custom Behaviors

Custom behaviors can be mounted into the crawler and loaded from there. For example:
Expand Down
6 changes: 5 additions & 1 deletion src/crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,11 @@ export class Crawler {

logger.info("Seeds", this.seeds);

logger.info("Behavior Options", this.params.behaviorOpts);
if (this.params.behaviorOpts) {
logger.info("Behavior Options", this.params.behaviorOpts);
} else {
logger.info("Behaviors disabled");
}

if (this.params.profile) {
logger.info("With Browser Profile", { url: this.params.profile });
Expand Down
12 changes: 8 additions & 4 deletions src/util/argParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,14 @@ class ArgParser {

// background behaviors to apply
const behaviorOpts: { [key: string]: string | boolean } = {};
argv.behaviors.forEach((x: string) => (behaviorOpts[x] = true));
behaviorOpts.log = BEHAVIOR_LOG_FUNC;
behaviorOpts.startEarly = true;
argv.behaviorOpts = JSON.stringify(behaviorOpts);
if (argv.behaviors.length > 0) {
argv.behaviors.forEach((x: string) => (behaviorOpts[x] = true));
behaviorOpts.log = BEHAVIOR_LOG_FUNC;
behaviorOpts.startEarly = true;
argv.behaviorOpts = JSON.stringify(behaviorOpts);
} else {
argv.behaviorOpts = "";
}

argv.text = argv.text || [];

Expand Down

0 comments on commit 39c8f48

Please sign in to comment.