Skip to content

Implement GDPR-compliant legal crawler and integrate into preprocessi…#70

Merged
lauxenz merged 2 commits into
devfrom
66-feature-implement-generic-contact-address-extractor
Jul 11, 2026
Merged

Implement GDPR-compliant legal crawler and integrate into preprocessi…#70
lauxenz merged 2 commits into
devfrom
66-feature-implement-generic-contact-address-extractor

Conversation

@lauxenz

@lauxenz lauxenz commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

…ng pipeline

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Impressum/legal notice” crawler to enrich scraped organization records with GDPR-safer contact details (generic emails + physical address), and integrates that enrichment step into the Philea preprocessing pipeline.

Changes:

  • Introduces preprocessing.extract_impressum with URL discovery, generic-email whitelisting, address heuristics, and a small crawl flow.
  • Adds unit tests for the new crawler/extraction helpers.
  • Integrates optional contact enrichment into run_pipeline.py (with a --skip-contact-crawler flag).

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 7 comments.

File Description
src/preprocessing/extract_impressum.py New module implementing link prioritization + generic email/address extraction and an “impressum” crawl flow.
src/tests/test_impressum.py New unit tests covering domain parsing, link extraction, email/address extraction, and crawl flow via mocked requests.
src/pipelines/run_pipeline.py Adds a preprocessing-time enrichment pass (Philea only) plus a CLI flag to skip the crawler.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/preprocessing/extract_impressum.py
Comment on lines +56 to +59
def get_base_domain(url):
"""
Extracts the registered base domain (e.g. example.com) from a URL.
"""
Comment on lines +302 to +304
]
if len(prev_line) < 60 and not any(k in prev_line.lower() for k in forbidden_words):
org_name = prev_line
Comment on lines +326 to +329
candidate = re.sub(r'(?i)\b(tel|phone|telefon|fax|mobil|mobile|t\b|f\b)[:\s]*\+?[\d\s\-\(\)/]+', '', candidate).strip()
# Filter out standard keywords and mail symbols
if "@" not in candidate and "http" not in candidate.lower() and len(candidate) > 5:
return candidate
Comment thread src/tests/test_impressum.py Outdated
Comment thread src/preprocessing/extract_impressum.py Outdated
Comment on lines +409 to +415
# Fill missing data
if sub_emails and not email_res:
email_res = sub_emails[0]
source_page = target_url
if sub_address and not address:
address = sub_address
source_page = target_url
Comment thread src/pipelines/run_pipeline.py Outdated
Comment on lines +212 to +223
logging.info(f"[{i}/{len(members)}] Crawling missing contact info for: {member['name']} ({member['website']})")
try:
impressum = crawl_impressum(member["website"], timeout=8)
if impressum:
if email_missing and impressum.get("generic_email"):
member["email"] = impressum["generic_email"]
logging.info(f" -> Found email: {impressum['generic_email']}")
if address_missing and impressum.get("address"):
member["address"] = impressum["address"]
logging.info(f" -> Found address: {impressum['address']}")
except Exception as e:
logging.warning(f" -> Failed to crawl {member['name']}: {e}")
@lauxenz lauxenz merged commit 8a28b6c into dev Jul 11, 2026
@lauxenz lauxenz deleted the 66-feature-implement-generic-contact-address-extractor branch July 11, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants