You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无SalesForce管理员权限,如何批量导出Contacts列表所有字段?

How to export full Salesforce Contact list (5000+ entries) when only 25 load at a time and no admin access?

Basic Context

I can access a Salesforce page with 5000+ Contacts, but the page only loads 25 contacts at a time—copy-pasting isn't feasible. Clicking into a contact shows more details, but my core need is to get the full list. I don't have access to the admin portal, only view permissions for Contacts and specific content.

The page URL structure looks like this:
https://example.force.com/example/_ui/search/ui/UnifiedSearchResults?offset=25&fpg=1cjmlvhdxsqly&str=epsilon-mu&sen=&fen=003&initialViewMode=detail&relatedListId=Contact&aId=_1527023282480&cookieParam=cookieParam1527023882485&tyme=1527023282485

My View

Salesforce Contact List View

Question

Are there feasible methods (like Python/bash scripts, URL modifications, web scraping, etc.) to export the list to .csv/.txt, or load the full list directly for copy-pasting?


Great question—this is a super common pain point with Salesforce's paginated views when you don't have admin-level export permissions. Let's break down the most feasible methods for you:

Method 1: Scrape via URL Offset Parameter (Python)

Your URL already includes an offset=25 parameter, which tells Salesforce how many records to skip. You can leverage this to iterate through all pages programmatically. Here's a basic Python script to do this:

First, capture your session cookies from your browser (since you're already logged in). Use your browser's dev tools (F12) to copy relevant cookies like sid and cookieParam from your URL example.

import requests
from bs4 import BeautifulSoup
import csv
import time

# Replace with your actual session cookies and base URL
session = requests.Session()
session.cookies.update({
    'sid': 'your_session_id',
    'cookieParam': 'cookieParam1527023882485'  # Use the value from your URL
})

base_url = "https://example.force.com/example/_ui/search/ui/UnifiedSearchResults?offset={}&fpg=1cjmlvhdxsqly&str=epsilon-mu&sen=&fen=003&initialViewMode=detail&relatedListId=Contact&aId=_1527023282480&tyme=1527023282485"

all_contacts = []
offset = 0

while True:
    url = base_url.format(offset)
    response = session.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    
    # Adjust selectors to match your page's contact elements
    contacts = soup.find_all('tr', class_='dataRow')  # Replace with actual class from your page
    if not contacts:
        break  # No more contacts to load
    
    for contact in contacts:
        # Extract fields (customize based on your page's HTML structure)
        name = contact.find('td', role='gridcell').text.strip()  # Example selector
        email = contact.find('td', {'data-label': 'Email'}).text.strip()
        phone = contact.find('td', {'data-label': 'Phone'}).text.strip()
        all_contacts.append([name, email, phone])
    
    offset += 25
    time.sleep(1)  # Avoid hitting Salesforce rate limits

# Save to CSV
with open('salesforce_contacts.csv', 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['Name', 'Email', 'Phone'])  # Header row
    writer.writerows(all_contacts)

print(f"Successfully exported {len(all_contacts)} contacts to salesforce_contacts.csv")

Note: Inspect your page's HTML (right-click > Inspect) to get the correct CSS selectors for contact rows and fields. Keep request delays reasonable to avoid being blocked.

Method 2: Browser Console Script (No External Tools)

If you don't want to use Python, run a JavaScript script directly in your browser's console (F12 > Console tab) to auto-load all pages and export data:

// Customize these selectors to match your page
const contactRowSelector = 'tr.dataRow';
const fieldSelectors = {
    name: 'td[data-label="Name"]',
    email: 'td[data-label="Email"]',
    phone: 'td[data-label="Phone"]'
};

let allContacts = [];

async function loadAndScrape() {
    // Wait for page content to load
    await new Promise(resolve => setTimeout(resolve, 1200));
    
    // Scrape current page
    const rows = document.querySelectorAll(contactRowSelector);
    rows.forEach(row => {
        const contact = {};
        for (const [key, selector] of Object.entries(fieldSelectors)) {
            contact[key] = row.querySelector(selector)?.textContent.trim() || '';
        }
        allContacts.push(contact);
    });
    
    // Find and click next page button
    const nextButton = document.querySelector('button[title="Next"]'); // Replace with actual next button selector
    if (nextButton && !nextButton.disabled) {
        nextButton.click();
        loadAndScrape();
    } else {
        // Export to CSV
        const headers = Object.keys(fieldSelectors);
        const csvContent = "data:text/csv;charset=utf-8," 
            + headers.join(",") + "\n" 
            + allContacts.map(e => headers.map(h => `"${e[h]}"`).join(",")).join("\n");
        
        const encodedUri = encodeURI(csvContent);
        const link = document.createElement("a");
        link.setAttribute("href", encodedUri);
        link.setAttribute("download", "salesforce_contacts.csv");
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        console.log(`Exported ${allContacts.length} contacts successfully!`);
    }
}

// Start the process
loadAndScrape();

Tip: Right-click the "Next" button on your Salesforce page and select "Inspect" to get the correct selector for nextButton.

Method 3: Check for Hidden Built-in Export Options

Before scraping, double-check if Salesforce has a native export option you missed:

  • Look for a dropdown menu (often labeled "More" or with a gear icon) at the top of the contact list.
  • Try creating a custom report via the "Reports" tab—some non-admin users can export reports to CSV even without full admin access.

Method 4: Salesforce REST API (If You Have API Access)

If your user profile has API permissions (even without admin access), this is the most reliable method. Here's a quick Python example:

import requests
import csv

# Replace with your OAuth credentials and instance URL
access_token = 'your_access_token'
instance_url = 'https://example.force.com'

# Match your search filter from the page
query = "SELECT Name, Email, Phone FROM Contact WHERE Name LIKE '%epsilon-mu%'"
url = f"{instance_url}/services/data/v58.0/query?q={requests.utils.quote(query)}"

all_contacts = []

while url:
    response = requests.get(url, headers={'Authorization': f'Bearer {access_token}'})
    data = response.json()
    all_contacts.extend(data['records'])
    url = data.get('nextRecordsUrl')

# Save to CSV
with open('contacts_api.csv', 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['Name', 'Email', 'Phone'])
    for contact in all_contacts:
        writer.writerow([contact['Name'], contact.get('Email', ''), contact.get('Phone', '')])

print(f"Exported {len(all_contacts)} contacts via API!")

Note: Check your profile permissions (Settings > Profile > API Enabled) to see if this is an option. If not, you might need to ask your admin for temporary API access.


内容的提问来源于stack exchange,提问作者About7Deaths

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:40:37