Implement GDPR-compliant legal crawler and integrate into preprocessi…#70
Merged
lauxenz merged 2 commits intoJul 11, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_impressumwith 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-crawlerflag).
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 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 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 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}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ng pipeline