#!/bin/bash # Function to fetch and append the body of the new page fetch_and_append() { local base_url="$1" local max_pages="$2" local compare_content="$3" local current_page=2 local original_content=$(lynx -dump "${base_url//\[insert_number\]/$current_page}") while [ "$current_page" -le "$((2 + max_pages))" ]; do current_page=$((current_page + 1)) local next_url="${base_url//\[insert_number\]/$current_page}" local new_content=$(lynx -dump -accept_all_cookies -nolist -width 2000 "$next_url" ) if [ "$compare_content" = "yes" ] && [ "$original_content" = "$new_content" ]; then break fi echo "$new_content" >> combined_page.txt original_content="$new_content" done } # Prompt for maximum number of pages to load read -p "Enter the maximum number of pages to load: " max_pages # Prompt to compare content read -p "Compare content to stop if the page is the same as the previous one? (yes/no): " compare_content # Initial URL with placeholder initial_url="https://www.example.com/page-[insert_number]" # Fetch and append pages fetch_and_append "$initial_url" "$max_pages" "$compare_content" echo "Pages have been combined into combined_page.txt"