Manual Data Broker Opt-Out Script

Build a Python script to automate privacy opt-outs

Welcome to another official UVF IT beginner build. Today we are constructing a minimal, privacy-first tool inspired by the open-source project remove-your-data. Instead of paying for subscription services, you will write a script that systematically visits data broker websites to submit removal requests.

This guide focuses on the core mechanic: identifying a target broker, extracting the necessary form fields, and submitting a removal request. We will build a working prototype that handles one major broker (Whitepages) to demonstrate the pattern, which you can then extend to others. No paid APIs or complex infrastructure are required.

Before You Begin

System Architecture
LOCAL ENVIRONMENT DATA BROKER SITES reads targets GET/POST requests Python Script requests + bs4 Config File JSON/YAML Whitepages.com Opt-Out Form
1

Phase 1: Scaffold and Dependencies

Create a new directory for your project. We will use a virtual environment to keep dependencies isolated. Install requests for HTTP calls and beautifulsoup4 for parsing HTML forms.

Initialize the project structure. We need a main script file and a configuration file where you will store your personal details (name, address) to be removed.

terminal

mkdir data-broker-remover
cd data-broker-remover
python3 -m venv venv
source venv/bin/activate
pip install requests beautifulsoup4
2

Phase 2: Define Target Data

Create a config.json file. This acts as your 'identity' for the script. It holds the name and address you want to remove from the broker. This separates data from logic, making it easy to update.

The script will read this file to populate the removal forms. Ensure the data matches what is publicly listed on the broker site.

config.json

{
  "first_name": "John",
  "last_name": "Doe",
  "address": "123 Main St",
  "city": "Anytown",
  "state": "CA",
  "zip": "12345"
}
3

Phase 3: Core Feature - Fetch and Parse Form

Write the main script remover.py. First, load the config. Then, use requests to fetch the opt-out page of a broker (e.g., Whitepages).

Use BeautifulSoup to find the HTML form. Most brokers have a form with hidden fields (like CSRF tokens or form IDs) that must be included in the submission. We will extract these automatically.

remover.py

import json
import requests
from bs4 import BeautifulSoup

# Load configuration
with open('config.json', 'r') as f:
    user_data = json.load(f)

# Target URL (Example: Whitepages opt-out form)
TARGET_URL = "https://www.whitepages.com/opt-out"

# Fetch the page
response = requests.get(TARGET_URL)
if response.status_code != 200:
    print(f"Failed to fetch page: {response.status_code}")
    exit(1)

# Parse HTML
soup = BeautifulSoup(response.text, 'html.parser')
form = soup.find('form')

if not form:
    print("No form found on the page.")
    exit(1)

print("Form found.")

# Extract hidden fields (e.g., CSRF tokens)
hidden_fields = {}
for input_tag in form.find_all('input', type='hidden'):
    name = input_tag.get('name')
    value = input_tag.get('value')
    if name and value:
        hidden_fields[name] = value

print(f"Extracted {len(hidden_fields)} hidden fields.")
4

Phase 4: Submit Removal Request

Now we submit the form. We need to map our user_data to the form's input fields. Inspect the broker's HTML (using browser DevTools) to find the name attributes for name, address, etc.

Add a delay after submission to be polite to the server. Print the response status to verify success.

remover.py

import requests
from bs4 import BeautifulSoup
import json
import time
import os

def load_config():
    with open('config.json', 'r') as f:
        return json.load(f)

def submit_removal_request(url, user_data):
    print(f"Fetching form from {url}...")
    response = requests.get(url)
    response.raise_for_status()
    
    soup = BeautifulSoup(response.text, 'html.parser')
    form = soup.find('form')
    
    if not form:
        print("No form found on the page.")
        return
    
    # Extract hidden fields
    hidden_fields = {}
    for input_tag in form.find_all('input', type='hidden'):
        if input_tag.get('name') and input_tag.get('value'):
            hidden_fields[input_tag['name']] = input_tag['value']
    
    # Map user data to form fields
    # Note: These field names are examples. You must inspect the target site's HTML
    # to find the correct 'name' attributes for the inputs you want to fill.
    payload = {
        'first_name': user_data.get('first_name', ''),
        'last_name': user_data.get('last_name', ''),
        'address': user_data.get('address', ''),
        'city': user_data.get('city', ''),
        'state': user_data.get('state', ''),
        'zip': user_data.get('zip', '')
    }
    
    # Combine hidden fields and user data
    payload.update(hidden_fields)
    
    print(f"Submitting removal request...")
    submit_url = form.get('action')
    if not submit_url or submit_url.startswith('/'):
        # Handle relative URLs
        from urllib.parse import urljoin
        submit_url = urljoin(url, submit_url)
    
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
    }
    
    response = requests.post(submit_url, data=payload, headers=headers)
    response.raise_for_status()
    
    print(f"Request submitted successfully. Status code: {response.status_code}")
    
    # Be polite
    time.sleep(5)

def main():
    config = load_config()
    url = "https://www.whitepages.com/opt-out"
    submit_removal_request(url, config)

if __name__ == "__main__":
    main()
5

Phase 5: Run and Verify

Run the script. It will fetch the page, extract hidden tokens, and submit your data. Check the console output for success.

Verify by visiting the broker site and searching for your name. Note that removals can take days to process. This script is a starting point; you will need to adapt the field names for each different broker.

terminal

python remover.py

Verifying the Stack

CheckCommand / Why it matters
Virtual environment activated and libraries installedpip list | grep requests
Config file created with valid JSONcat config.json
Script runs without errors and prints 'Form found'python remover.py
Script prints 'Request submitted successfully'python remover.py

Next Steps

This script handles one broker. To build a full 'Data Broker Removal' tool, create a list of URLs and loop through them, adjusting the form field mappings for each site. Always respect rate limits and terms of service.