Skip to content

HasData/extract-emails-from-google-search

Repository files navigation

Python Requests dotenv

Extract Emails From Google Search Results

HasData_bannner

Companion code for a YouTube video showing how to find publicly visible email addresses from Google search snippets with the HasData Google SERP API.

Lightweight tutorial project: query Google SERP data, extract emails from snippets, and rank the best match for a person.

Watch the video

This repository includes small Python examples for:

  • extracting every email found in search result snippets
  • choosing the most likely email for one person
  • processing a CSV file with multiple people and companies

Quick Start

pip install -r requirements.txt

Create .env:

HASDATA_API_KEY=your_api_key_here

Run the batch example:

python scraper_file_read.py

What This Project Does

The scripts build a Google-style search query from a person's name, company, and the word email, send that query to the HasData SERP API, and scan returned snippets for email addresses.

For matching mode, the project also compares the discovered email addresses with the target person's name and returns the closest candidate.

Workflow

Person + Company
       |
       v
Build Google-style query
       |
       v
Request SERP data from HasData
       |
       v
Extract emails from snippets
       |
       v
Return all matches or best match

Project Structure

extract-emails-from-google-search/
|-- README.md
|-- readme-example.md
|-- requirements.txt
|-- people_info.csv
|-- scraper.py
|-- scraper_email_match.py
|-- scraper_file_read.py
`-- utils.py

Requirements

  • Python 3.10+
  • A HasData API key

Install dependencies:

pip install -r requirements.txt

Configuration

Create a .env file in the project root:

HASDATA_API_KEY=your_api_key_here

The scripts load this variable automatically with python-dotenv.

Input File

Batch mode reads data from people_info.csv.

Expected format:

full_name,company
Roman Milyushkevich,Hasdata
Sergey Ermakovich,Hasdata

Scripts

scraper.py

The simplest example. It:

  1. builds a search query for one person
  2. requests Google SERP data from HasData
  3. extracts every email found in the organic result snippets
  4. prints the matches

Run:

python scraper.py

scraper_email_match.py

Single-person matching mode. It:

  1. searches for one person and company
  2. extracts emails from snippets
  3. scores each email against the target name
  4. prints the best candidate

Run:

python scraper_email_match.py

scraper_file_read.py

Batch mode for multiple people from CSV. It:

  1. reads people_info.csv
  2. searches for each person
  3. finds the best matching email
  4. prints the result person by person

Run:

python scraper_file_read.py

How Matching Works

Matching logic lives in utils.py.

  • extract_emails() finds valid email patterns in snippet text
  • name_email_similarity() compares the email local part with the target name
  • the highest similarity score wins

This is intentionally lightweight and easy to explain in a video, not a full identity-resolution system.

Example Search Pattern

The scripts generate a query in this form:

"FirstName" "LastName" CompanyName email

Example:

"Roman" "Milyushkevich" Hasdata email

Notes

  • Results depend on what Google snippets expose at request time.
  • This approach only finds emails that appear publicly in search snippets.
  • Accuracy is limited when multiple people share similar names.
  • API usage depends on your HasData account and quota.

Why This Repo Exists

This project is meant to be extra material for a YouTube tutorial, so the code stays small, readable, and easy to follow. The focus is on demonstrating the core idea clearly rather than building a production-grade enrichment pipeline.

Use Cases

  • lead research demos
  • enrichment experiments
  • tutorial material for scraping and SERP parsing
  • lightweight prospecting workflows

License

This project is licensed under the MIT License. See LICENSE.

About

Extract public emails from Google Search snippets with Python and the HasData SERP API. Includes email extraction, name-to-email matching, CSV batch lookup, and YouTube tutorial companion code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages