Adding a search feature to private conversations

Thread Starter

cmartinez

Joined Jan 17, 2007
8,722
That feature would come in very handy. Especially because I have a rather large collection of conversations that I'd like to revisit every now and then when I'm trying to remember, clarify or expand certain points.

Is there a particular reason why that feature has not been implemented?
 

joeyd999

Joined Jun 6, 2011
6,204
Mods and @jrap: I am in need of such a search function as well.

I have written a bash script to scrape my personal conversation pages in search of specific terms, but I haven't used it yet.

First, I wish to ensure that I am not breaking any forum rule by something that might look to the system like a bot. It will be pulling many pages very quickly, scanning every conversation and page of those conversations.

They will be pages only from my personal -- logged in -- conversations.

Please advise.

Thanks.
 

joeyd999

Joined Jun 6, 2011
6,204
As an alternative, I can scrape all my conversations once and archive and search locally. Are there any problems with this?
 

joeyd999

Joined Jun 6, 2011
6,204
You'll need to put a cookies.txt file in the same directory. There are chrome and firefox extensions that will do this for you.

Bash:
#!/bin/bash

# =============================================
# All About Circuits Conversations Regex Search
# Joeyd999@AAC March 2026
# Usage:
#   ./pms "regex_pattern"
#   ./pms "regex_pattern" conversations_list.txt
# =============================================

if [ $# -eq 0 ]; then
    echo "Error: Please provide at least a regex search pattern."
    echo "Usage:"
    echo "  $0 \"your regex pattern\""
    echo "  $0 \"your regex pattern\" conversations_list.txt"
    echo ""
    echo "Examples:"
    echo "  $0 \"MOSFET|op.?amp\""
    echo "  $0 \"gain\\s*=\\s*[0-9]+\""
    echo "  $0 \"\\bdriver\\b\""
    exit 1
fi

REGEX="$1"
COOKIE_FILE="cookies.txt"
BASE_URL="https://forum.allaboutcircuits.com"
MAX_PAGES_PER_CONV=100
OUTPUT_FILE="search_results.txt"

echo "Searching with regex: '$REGEX'" | tee "$OUTPUT_FILE"
echo "Using cookies: $COOKIE_FILE" | tee -a "$OUTPUT_FILE"

# Determine source of conversations
if [ $# -ge 2 ] && [ -f "$2" ]; then
    echo "Using conversation list from file: $2" | tee -a "$OUTPUT_FILE"
    mapfile -t CONV_URLS < <(grep -vE '^\s*#|^\s*$' "$2")
    echo "Loaded ${#CONV_URLS[@]} conversation(s) from file." | tee -a "$OUTPUT_FILE"
else
    echo "Fetching list of conversations from the site..." | tee -a "$OUTPUT_FILE"
    wget --quiet \
         --load-cookies "$COOKIE_FILE" \
         --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0 Safari/537.36" \
         -O conversations_list.html \
         "$BASE_URL/conversations/" 2>/dev/null

    mapfile -t CONV_URLS < <(grep -oP 'href="(/conversations/[^"]+/)"' conversations_list.html | \
                            sed "s|href=\"|$BASE_URL|" | sed 's/"$//')
    
    rm -f conversations_list.html
    echo "Found ${#CONV_URLS[@]} conversation(s)." | tee -a "$OUTPUT_FILE"
fi

echo "----------------------------------------" | tee -a "$OUTPUT_FILE"

# Process each conversation
for conv_url in "${CONV_URLS[@]}"; do
    # Extract a readable title from the URL
    title=$(basename "$conv_url" | sed 's/-[0-9]\+\/*$//' | tr '-' ' ' | sed 's/^ *//;s/ *$//')
    [ -z "$title" ] && title="Unknown Conversation"

    echo "→ Checking: $title" | tee -a "$OUTPUT_FILE"

    page=1
    while [ $page -le $MAX_PAGES_PER_CONV ]; do
        if [ $page -eq 1 ]; then
            page_url="$conv_url"
        else
            page_url="${conv_url%/}/page-$page"
        fi

        wget --quiet \
             --load-cookies "$COOKIE_FILE" \
             --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0 Safari/537.36" \
             --timeout=20 \
             -O "temp_page.html" \
             "$page_url" 2>/dev/null

        if [ ! -s "temp_page.html" ] || grep -qE "(No conversation found|could not be found|page not found|404)" "temp_page.html"; then
            rm -f temp_page.html
            break
        fi

        # Count regex matches (case-insensitive, extended regex)
        count=$(grep -Eio "$REGEX" "temp_page.html" | wc -l)

        if [ "$count" -gt 0 ]; then
            echo "   ✅ FOUND $count time(s) on page $page → $title" | tee -a "$OUTPUT_FILE"
            # Uncomment the next line to also show the direct page link:
            # echo "      Link: $page_url" | tee -a "$OUTPUT_FILE"
        fi

        rm -f temp_page.html
        ((page++))
    done
done

rm -f temp_page.html

echo "----------------------------------------" | tee -a "$OUTPUT_FILE"
echo "Search complete. Results saved to $OUTPUT_FILE" | tee -a "$OUTPUT_FILE"
 
Top