Tuesday work phone number script

#!/bin/bash

INPUT=”contacts.csv”
OUTPUT=”results.csv”

echo “Name,Phone,Found Name” > “$OUTPUT”

tail -n +2 “$INPUT” | while IFS=, read -r name phone
do
echo “Checking $phone…”

# Construct the URL
url=”https://www.searchyellowdirectory.com/reverse-phone/1671/$phone

# Fetch page and extract result using grep + sed (basic page title parsing)
found_name=$(curl -s “$url” | grep -o ‘.*’ | sed -E ‘s/<\/?title>//g’ | sed -E ‘s/.*for number [0-9]+ – (.*)/\1/’)

# Fallback if nothing found
if [[ -z “$found_name” || “$found_name” == *”No results found”* ]]; then found_name=”Not Found”
fi

echo “$name,$phone,$found_name” >> “$OUTPUT”
done

echo “✅ Done! See: $OUTPUT”

Leave a comment