Data Extractors¶
DataExtractor
¶
Bases: ABC
Base class for all data extractors
Source code in extract_emails/data_extractors/data_extractor.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
name
abstractmethod
property
¶
Name of the data extractor, e.g. email, linkedin
get_data(page_source)
abstractmethod
¶
Extract needed data from a string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_source
|
str
|
webpage content |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of data, e.g. {'email@email.com', 'email2@email.com'} |
Source code in extract_emails/data_extractors/data_extractor.py
12 13 14 15 16 17 18 19 20 21 | |
EmailExtractor
¶
Bases: DataExtractor
Source code in extract_emails/data_extractors/email_extractor.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
get_data(page_source)
¶
Extract emails from a string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_source
|
str
|
webpage content |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of emails, e.g. {'email@email.com', 'email2@email.com'} |
Source code in extract_emails/data_extractors/email_extractor.py
17 18 19 20 21 22 23 24 25 26 27 | |
AdvancedEmailExtractor
¶
Bases: DataExtractor
Advanced email extractor with support for obfuscated and Cloudflare-protected emails.
Source code in extract_emails/data_extractors/advanced_email_extractor.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
name
property
¶
Name of the data extractor.
Returns:
| Type | Description |
|---|---|
str
|
"email" |
cf_decode_email(encoded)
¶
Decode Cloudflare-protected email from data-cfemail attribute.
Decodes email addresses that are obfuscated by Cloudflare's email protection feature using XOR encryption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
str
|
Hex-encoded email string from data-cfemail attribute. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded email address. |
Source code in extract_emails/data_extractors/advanced_email_extractor.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
get_data(page_source)
¶
Extract emails from a webpage with support for obfuscated and protected emails.
Extracts email addresses using multiple strategies: 1. Regex matching on preprocessed text (handles common obfuscations) 2. Decoding Cloudflare-protected emails from data-cfemail attributes
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_source
|
str
|
HTML webpage content. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of extracted email addresses. |
Source code in extract_emails/data_extractors/advanced_email_extractor.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
is_junk(email)
¶
Filter likely junk/system emails.
Checks if an email address appears to be a system or junk email based on various heuristics like length, hex patterns, and known junk domains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
Email address to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the email appears to be junk, False otherwise. |
Source code in extract_emails/data_extractors/advanced_email_extractor.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
preprocess(text)
¶
Normalize common obfuscations to standard email format.
Replaces common email obfuscation patterns like "[at]", "(at)", " at " with "@" and "[dot]", "(dot)", " dot " with ".".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text content that may contain obfuscated email addresses. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Text with obfuscations normalized to standard email format. |
Source code in extract_emails/data_extractors/advanced_email_extractor.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
LinkedinExtractor
¶
Bases: DataExtractor
Source code in extract_emails/data_extractors/linkedin_extractor.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
get_data(page_source)
¶
Extract links to Linkedin profiles
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_source
|
str
|
webpage content |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of urls, e.g. {'https://www.linkedin.com/in/venjamin-brant-73381ujy3u'} |
Source code in extract_emails/data_extractors/linkedin_extractor.py
16 17 18 19 20 21 22 23 24 25 26 27 28 | |