Web Scraping for Lead Generation: What's Fair Game and How to Build It Right

Web scraping can feed your pipeline with real buying signals, or land you in a privacy mess. Here's what's fair game, why official APIs come first and how to build a scraper you can defend.

Pixel-art browser window beside a magnifier, picking public company signals off the web for sales outreach.

Web scraping for lead generation means using code to collect public data from websites and turn it into a list of accounts to sell to. It works best for company signals like job posts, directory listings, reviews and tech footprints. Use official APIs first, respect robots.txt and site terms, and treat any personal data with care.

Scraping has a bad name in sales, and some of it is earned. Most of the bad name comes from one move: pulling people's names and emails off sites that never agreed to it, then blasting them.

That's not what I'm talking about. The useful kind of scraping collects facts about companies. Who is hiring for the role you sell to? Who runs the tool you replace? Who got three bad reviews about a competitor this month? Those signals tell you who to call and when.

This guide covers what's legal and ethical, which public data is worth the effort, why APIs come first, how to build a scraper with n8n or code and how to keep the data clean. One note before we start: I'm a marketer, not a lawyer. Nothing here is legal advice.

Key takeaways

  • Scrape companies, not people. Company signals carry most of the value and less of the risk.
  • Official APIs come first. They're more stable, often allowed and already structured.
  • Robots.txt is a request, not a permission slip. Respect it anyway.
  • Public isn't the same as free to use. Privacy law can still cover public personal data.
  • Quality beats volume. A clean list of 300 accounts beats a messy list of 30,000.

What is web scraping for lead generation?

Web scraping is using code to fetch web pages and pull out specific facts. For lead generation, those facts help you decide which companies to target and when to reach out.

Here's how it works. A script or workflow asks a website for a page, the same way your browser does. It reads the HTML that comes back. It finds the parts you care about, like a job title or a review score. Then it saves them in a table, matches them to companies and sends the useful ones to your CRM.

A scraper is only one way to get public data. Others include official APIs, data feeds and licensed data providers. Scraping is the last resort, not the first move. I'll come back to why.

The goal is not a giant list. It's a short list of the right accounts with a reason to call now. That's what makes scraped data worth having. The guide to B2B buying signals covers which signals predict a sale.

Is web scraping for lead generation legal and ethical?

There are three layers to think about. Each one asks a different question.

Layer The question What to do
Access rules Does the site allow automated access to this page? Read robots.txt and the site's terms
Personal data law Does the data identify a person? Check GDPR, UK GDPR, CCPA and local law
Your own ethics Would the people involved be surprised or upset? Collect less, use it fairly, delete it on time

Again, this is not legal advice. Rules differ by country, by state and by site. If your program stores data about people, have a lawyer look at it before you scale.

What does robots.txt allow?

Robots.txt is a file at the root of a site that tells crawlers which paths to skip. The standard is RFC 9309, the Robots Exclusion Protocol, published in September 2022.

The key line is plain: "These rules are not a form of access authorization." In other words, robots.txt doesn't make scraping legal. It's the site owner's stated wish. The RFC also says crawlers shouldn't use a cached copy for more than 24 hours, unless the file is unreachable.

My rule is simple. If robots.txt says skip a path, skip it. It costs you little and shows good faith.

What do site terms say?

A site's terms of use often say whether you may use bots, scrapers or automated tools. Read them before you build anything. If the terms bar scraping, don't scrape that site. Find an API, a licensed source or a different signal.

This is also why I don't scrape LinkedIn, and I don't recommend it. Use it by hand, the way it's meant to be used. Get people data from licensed providers or your own first-party sources instead.

What about personal data under GDPR?

If the data can identify a person, privacy law applies, even if the page is public. In the UK and EU, that means GDPR. Most B2B prospecting relies on a lawful basis called legitimate interests.

The UK regulator, the ICO, describes legitimate interests as a three-part test. Are you pursuing a legitimate interest? Is the processing necessary for it? Do the person's interests override yours? The ICO says you should do and record a legitimate interests assessment. It also says you must consider people's reasonable expectations, and you must stop direct marketing when someone objects.

Regulators are watching scraping closely. In October 2024, the ICO and 16 other data protection authorities issued a joint follow-up statement on data scraping. It describes scraping as pulling data from sites that host publicly accessible personal information. It calls for safeguards against unlawful scraping. Public does not mean fair game.

The guide to GDPR and cold email covers outreach rules in more depth.

What about the CCPA in California?

California's privacy law covers personal information of California residents. The California Attorney General's CCPA page says personal information "does not include publicly available information." That sounds like a free pass. It isn't one. The term has a legal meaning, so don't assume every page you can open counts.

The same page says the law applies to for-profit businesses that do business in California and meet one of three tests. One is gross annual revenue over $25 million. Another is buying, selling or sharing the personal information of 100,000 or more California residents or households. The third is getting half or more of revenue from selling it. If you're near any of these, get legal advice.

Which public data is worth collecting?

Most scraping projects collect too much of the wrong thing. Here's the public data that actually helps you sell, ranked by how much I trust it.

Data What it tells you Where to get it Personal data risk
Job posts The company is hiring in your buyer's team, or for a skill your tool replaces Public job board APIs, careers pages Low
Tech footprints Which tools a company runs on its site Page source, script tags, DNS records Low
Directory listings Who is in a market, by category and location Industry and member directories Low to medium
Review sites Pain with a competitor, or a new category entry Review platforms, ideally through their APIs Medium
News and press pages Funding, launches, new leaders Company newsrooms, press feeds Low to medium
Pricing and feature pages Plan changes, new products, packaging shifts Competitor and prospect websites Low

Job posts

Job posts are my favorite signal. A company hiring three sales reps likely needs sales tools. A company hiring its first RevOps lead is about to rebuild its stack. Each post is a hiring signal with a date, a team and a job description that spells out the pain.

Tech footprints

What a company runs on its own website is public. Script tags, tracking pixels and DNS records show the tools in use. That's technographics, and the guide to tech install signals covers how to use it.

Directories and reviews

Directories help you build a market map, like every agency in a trade group. Reviews show pain. A cluster of bad reviews about a competitor's support is a reason to reach out to those accounts. Many review platforms limit automated access, so check terms and look for an API or partner program first.

Why should you use official APIs first?

An official API is a door the site built for you. A scraper climbs through the window. Use the door whenever there is one.

APIs return structured data, usually as JSON. They change less often than page layouts. They come with documented limits. And they're far more likely to be allowed by the site's terms.

Job boards are the best example. Greenhouse, a hiring platform many tech companies use, documents a public Job Board API. Listing a company's open jobs is one GET request to a URL with the company's board token, and it needs no login. Only submitting an application needs authentication. The docs also say requests may be rate limited.

That's one request per company, with clean fields for title, department and location. No HTML parsing. No layout changes breaking your workflow every month.

Here's the order I follow:

  1. Official API. Documented, structured and usually allowed.
  2. Licensed data provider. Someone else handles the collection and the rights.
  3. Public feeds. RSS, sitemaps and data exports the site offers on purpose.
  4. Gentle scraping. Only when the data is public, the terms allow it and nothing above exists.

Respect every API rate limit, even when it's not written down. If you get blocked, you've gone too fast.

How do you build a responsible scraper with n8n or code?

You don't need a big platform for this. A small workflow in n8n or a short script handles most B2B signal collection. Here's the build I use.

Flow from checking access to API first, gentle fetching, parsing, matching and expiring data, with API first in orange.Flow from checking access to API first, gentle fetching, parsing, matching and expiring data, with API first in orange.
Most of the work in a responsible scraper happens before and after the fetch, not during it.

The workflow, step by step

  1. Write the question first. "Which of our 500 target accounts are hiring a RevOps role?" beats "get all job posts."
  2. Check access rules. Read robots.txt and the terms for every source. Log what you checked and when.
  3. Use the API if there is one. Only fall back to fetching pages when there isn't.
  4. Fetch gently. Add a wait between requests, run off-peak and set a clear user agent that names your company.
  5. Parse only what you need. Pull the job title, team and date. Leave the rest.
  6. Store the minimum. Company, signal, date, source URL. No personal data unless you have a documented reason.
  7. Match and dedupe. Tie each signal to an account in your CRM.
  8. Expire old data. Delete or archive signals after a set window.

Doing it in n8n

In n8n, the HTTP Request node fetches a page or calls an API. The HTML node then pulls out what you need. Its Extract HTML Content operation takes a CSS selector and returns the text, the HTML, an attribute or a form value. Options trim spaces and clean up line breaks.

A typical flow runs on a schedule. It reads your account list, calls each company's job board API, filters titles that match your buyer, then writes matches to your CRM. Add a Wait node between calls. The guide to GTM engineering with n8n covers the patterns for scheduling, error handling and retries.

When to switch to code

Some pages only load their content after JavaScript runs. A plain HTTP request gets an empty shell. For those, you need a headless browser, which is a real browser your code drives without a screen. That's heavier, slower and more likely to annoy a site. So ask again whether there's an API or a feed first.

How do you keep scraped data quality high?

Scraped data goes stale fast and arrives messy. Without a quality step, you'll flood your CRM with junk and your reps will stop trusting it.

Check What it catches How to do it
Deduplication The same job post from two sources Match on company domain plus title plus date
Account match Signals for companies you can't sell to Match on domain to your account list
Normalization "Sr. RevOps Mgr" and "Senior Revenue Operations Manager" Map titles to a short list of roles
Data freshness Job posts that closed months ago Stamp a seen date, drop anything not seen in 30 days
Source logging Not knowing where a fact came from Store the source URL and fetch date on every row
Volume alerts A layout change that breaks the parser Alert when a run returns far fewer rows than usual

The last one matters more than people think. Scrapers rarely crash. They quietly return nothing when a site changes its layout. A simple alert on row counts catches that.

Write the rules down as a data contract between the workflow and the CRM: which fields, what format, how fresh. The post on data contracts for GTM shows how.

Worked example: hiring signals from job board APIs

This is a worked example with assumed numbers. Use your own.

Funnel: 500 target accounts, 140 with a readable job board, 35 posting a sales role and 12 meetings booked.Funnel: 500 target accounts, 140 with a readable job board, 35 posting a sales role and 12 meetings booked.
Worked example from this guide with assumed rates, using public job board APIs checked once a week.

Say you sell a sales tool to B2B companies with 50 to 500 staff. You have 500 target accounts. You want to know which ones are hiring sales reps right now.

You build an n8n workflow that checks each account's public job board API once a week. Of your 500 accounts, 140 have a board you can read. In a given month, 35 of those post at least one sales role. Reps reach out to all 35 with a note about the hire. That turns into 12 meetings.

The point isn't the exact rates. It's that a narrow, timely signal on a short list beats a huge list with no reason to call. If you'd rather not build it, the data enrichment use case shows how I set this up for clients.

What are the common web scraping mistakes?

Scraping people instead of companies. It adds legal risk and rarely adds pipeline. Collect company signals and source contacts elsewhere.

Skipping the API. Many teams build a fragile scraper for data the site already offers through a public API.

Going too fast. Hammering a site gets you blocked and can cause it real harm. Wait between requests.

Ignoring terms. If the terms bar automated access, find another source.

Never expiring data. A job post from six months ago is not a signal. Set a window and delete old rows.

No monitoring. Layouts change. Without row count alerts, you won't notice your data stopped flowing.

Dumping raw data in the CRM. Unmatched, undeduped rows clog the CRM and burn rep trust. Clean first, then sync.

What should you do this week?

My GTM engineering service builds signal workflows like this end to end, with the access checks, dedupe and CRM sync included.

My take: collect signals, not people

The best scraping programs I've seen look boring. They collect a handful of company facts from a few good sources, mostly through APIs. They match them to a short account list. They throw old data away.

The worst ones try to rebuild a contact database from scratch. They're slow, fragile and risky, and the list is stale before it's used.

So use the door, not the window. Respect robots.txt and the terms. Keep people data out unless you have a clear reason and a lawful basis. Then spend your effort on what matters: getting the right signal to the right rep while it's still fresh.

FAQ

Is web scraping for lead generation legal?

It depends on what you collect, where you collect it from and where the people in the data live. Scraping company facts from public pages is lower risk than collecting personal data. Site terms, robots.txt and privacy laws like GDPR and the CCPA all apply. This is not legal advice, so have a lawyer review any program that stores data about people.

Does robots.txt make scraping legal or illegal?

No. The robots.txt standard says its rules are not a form of access authorization. It's a request from the site owner about which paths crawlers should visit. Following it is good manners and good evidence of good faith. Ignoring it can break a site's terms and hurt your case if something goes wrong, so respect it.

Can I scrape LinkedIn for leads?

I don't recommend it, and I don't do it. Use LinkedIn the way it's meant to be used, by hand, and get people data from licensed providers or your own first-party sources. For company signals, public job boards with official APIs, review sites and company websites give you plenty to work with.

What data is worth scraping for B2B lead generation?

Company signals are worth the most: job posts that show hiring in your buyer's team, directory listings that define a market, reviews that show pain with a competitor and tech footprints that show what tools a company runs. These tell you who to target and when. Personal contact details are better sourced from licensed providers.

Should I use an API or a scraper?

Use an official API first whenever one exists. APIs are more stable, often allowed by the site's terms and return clean structured data. Many job boards, for example, publish public job board APIs. Scrape only when there's no API, the data is public, the terms allow it and you can collect it gently.

Can I build a scraper in n8n?

Yes. A simple n8n workflow uses the HTTP Request node to fetch a page and the HTML node to pull out the parts you need with CSS selectors. Add a wait between requests, a check for robots.txt, a dedupe step and a write to your database or CRM. For pages that need a real browser, use code or a hosted tool.

More like this

Startup? Let's talk.

20 minute fit call. You'll leave knowing the first thing we'd fix and roughly what it costs. If we're not the right fit, we'll tell you who is.