Scraping email python

Shinto74350

Newbie
Joined
May 7, 2025
Messages
5
Reaction score
3
Hello everyone, I'm looking for a way to collect artists' emails in bulk.

I created a Python program for this, but it seems I'm completely blocked by Google. Does anyone have a Python program that can scrape emails?

I found ways to retrieve emails using Google scraping, but it's quite time-consuming.

Here's my code (Claude AI):

import re
import requests
from bs4 import BeautifulSoup
import time

headers = {
“User-Agent”: (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
“Chrome/124.0.0.0 Safari/537.36”
)
}

def extract_google_links(google_search_url):
"""Gets real links from a Google search page."""
try:
r = requests.get(google_search_url, headers=headers, timeout=10)
soup = BeautifulSoup(r.text, 'html.parser')
links = []

for a in soup.find_all("a"):
href = a.get("href")
if href and "/url?q=" in href:
url = href.split("/url?q=")[1].split("&")[0]
if not url.startswith("http"):
continue
links.append(url)

return links
except Exception as e:
print(f"[Google Error] {e}")
return[]

def extract_emails_from_url(url):
"""Retrieves all emails from a web page."""
try:
r = requests.get(url, headers=headers, timeout=10)
soup = BeautifulSoup(r.text, 'html.parser')
emails = set(re.findall(
r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}",
soup.get_text()
))
return emails
except Exception as e:
print(f"[Site error] {url} → {e}")
return set()

# -----------------------------
# User input
# -----------------------------
print("Paste Google search URLs (one per line). Type '/' to launch:\n")

urls = []
while True:
line = input()
if line.strip() == "/":
break
if line.strip():
urls.append(line.strip())

print(f"\n {len(urls)} Google requests received. Start of scraping...\n")

all_emails = set()

for google_url in urls:
print(f"\n Google query: {google_url}")
links = extract_google_links(google_url)
print(f" ➜ {len(links)} links found")

for link in links:
print(f" ➤ Reading from: {link}")
emails = extract_emails_from_url(link)

for email in emails:
if email not in all_emails:
all_emails.add(email)
print("", email)

time.sleep(3) # Pause to avoid blocking

# -----------------------------
# Final result
# -----------------------------
print(f"\n✅ Scraping complete. {len(all_emails)} unique emails found:\n")
for email in sorted(all_emails):
print("-", email)
 
Hello everyone, I'm looking for a way to collect artists' emails in bulk.

I created a Python program for this, but it seems I'm completely blocked by Google. Does anyone have a Python program that can scrape emails?

I found ways to retrieve emails using Google scraping, but it's quite time-consuming.

Here's my code (Claude AI):

import re
import requests
from bs4 import BeautifulSoup
import time

headers = {
“User-Agent”: (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
“Chrome/124.0.0.0 Safari/537.36”
)
}

def extract_google_links(google_search_url):
"""Gets real links from a Google search page."""
try:
r = requests.get(google_search_url, headers=headers, timeout=10)
soup = BeautifulSoup(r.text, 'html.parser')
links = []

for a in soup.find_all("a"):
href = a.get("href")
if href and "/url?q=" in href:
url = href.split("/url?q=")[1].split("&")[0]
if not url.startswith("http"):
continue
links.append(url)

return links
except Exception as e:
print(f"[Google Error] {e}")
return[]

def extract_emails_from_url(url):
"""Retrieves all emails from a web page."""
try:
r = requests.get(url, headers=headers, timeout=10)
soup = BeautifulSoup(r.text, 'html.parser')
emails = set(re.findall(
r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}",
soup.get_text()
))
return emails
except Exception as e:
print(f"[Site error] {url} → {e}")
return set()

# -----------------------------
# User input
# -----------------------------
print("Paste Google search URLs (one per line). Type '/' to launch:\n")

urls = []
while True:
line = input()
if line.strip() == "/":
break
if line.strip():
urls.append(line.strip())

print(f"\n {len(urls)} Google requests received. Start of scraping...\n")

all_emails = set()

for google_url in urls:
print(f"\n Google query: {google_url}")
links = extract_google_links(google_url)
print(f" ➜ {len(links)} links found")

for link in links:
print(f" ➤ Reading from: {link}")
emails = extract_emails_from_url(link)

for email in emails:
if email not in all_emails:
all_emails.add(email)
print("", email)

time.sleep(3) # Pause to avoid blocking

# -----------------------------
# Final result
# -----------------------------
print(f"\n✅ Scraping complete. {len(all_emails)} unique emails found:\n")
for email in sorted(all_emails):
print("-", email)

Google became strictly on scraping aggressively these days, so getting blocked is expected, especially if you do it with repeated requests from the same IP..
 
Back
Top