B2B Lead Automation
by @nicemaths123
Automate extraction and structuring of publicly available B2B business contacts from directories and listings for CRM-ready lead generation.
Extract Company Contacts from LinkedIn
import ApifyClient from 'apify-client';const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor("apify/linkedin-companies-scraper").call({
startUrls: [
{ url: "https://www.linkedin.com/company/salesforce/" },
{ url: "https://www.linkedin.com/company/hubspot/" }
],
maxResults: 50
});
const { items } = await run.dataset().getData();
// Each item contains:
// { name, website, industry, employeeCount,
// headquarters, description, linkedinUrl }
Scrape Yellow Pages for Local Business Leads
const run = await client.actor("apify/yellowpages-scraper").call({
searchTerms: ["digital marketing agency"],
locations: ["New York, NY", "Los Angeles, CA", "Chicago, IL"],
maxResultsPerPage: 30
});const { items } = await run.dataset().getData();
// Each item contains:
// { businessName, phone, address, city, state,
// zip, website, category, email }
Extract Leads from Google Maps (Local Businesses)
const run = await client.actor("apify/google-maps-scraper").call({
searchStringsArray: ["accountants in Austin TX", "law firms in Miami FL"],
maxCrawledPlacesPerSearch: 50,
language: "en"
});const { items } = await run.dataset().getData();
// Each item contains:
// { title, address, phone, website, rating,
// reviewsCount, category, email, plusCode }
Multi-Source Lead Aggregation Pipeline
const [ypRun, gmRun] = await Promise.all([
client.actor("apify/yellowpages-scraper").call({
searchTerms: ["IT consulting"],
locations: ["San Francisco, CA"],
maxResultsPerPage: 25
}),
client.actor("apify/google-maps-scraper").call({
searchStringsArray: ["IT consulting San Francisco CA"],
maxCrawledPlacesPerSearch: 25
})
]);const [ypData, gmData] = await Promise.all([
ypRun.dataset().getData(),
gmRun.dataset().getData()
]);
// Normalize and deduplicate by website domain
const allLeads = [...ypData.items, ...gmData.items];
const uniqueLeads = allLeads.filter(
(lead, index, self) =>
index === self.findIndex(l => l.website === lead.website)
);
console.log(${uniqueLeads.length} unique leads collected);
maxResultsPerPage to 25β100 to control costs and avoid rate limitingclawhub install b2b-lead-automation