A library to extract IPs, domains, and emails from text
Project description
Parsextract
Parsextract is a Python library that extracts IP addresses, domains, and email addresses from raw text. It supports validation against IANA-recognized TLDs and includes additional custom TLDs sourced from OpenNIC.
Features
- Extracts IPv4 addresses from raw text.
- Extracts domain names and validates them against IANA and OpenNIC TLDs.
- Extracts email addresses using regex-based parsing.
- Lightweight and easy to integrate.
Installation
pip install parsextract
Usage
import parsextract
text = """
Contact us at support@example.com or visit https://mywebsite.geek for more info.
Our server IP is 192.168.1.1.
"""
# Extract IPs
ips = parsextract.extract_ips(text)
print("IPs:", ips)
# Extract Domains
domains = parsextract.extract_domains(text)
print("Domains:", domains)
# Extract Emails
emails = parsextract.extract_emails(text)
print("Emails:", emails)
Example Output
IPs: ['192.168.1.1']
Domains: ['mywebsite.geek']
Emails: ['support@example.com']
Regular Expressions Used
- IP Address Regex:
(?i)(?<![a-zA-Z0-9:.])(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])){3}(?![a-zA-Z0-9/.]) - Domain Regex:
(?i)(?:^|\s|["']|[,])((?:(?:[A-Z0-9_](?:[A-Z0-9_-]{0,61}[A-Z0-9_])?\.)+)(?:[A-Z0-9-]{1,63}(?<!-)))(?!(?:/[^\s/]+))(?![a-zA-Z0-9@]) - Email Regex:
(?<!@)\b[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]{2,}\b(?!@)
Supported TLDs
The library validates domains using IANA-approved TLDs and additional custom TLDs from OpenNIC.
Custom TLDs Supported:
.bbs, .chan, .cyb, .dyn, .epic, .geek, .gopher, .indy, .libre, .neo, .null,
.o, .oss, .oz, .parody, .pirate
License
This project is licensed under the MIT License.
Contributing
Feel free to open an issue or submit a pull request for improvements.
Author
Maintained by deepak.kumar@cyware.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file parsextract-0.1.10.tar.gz.
File metadata
- Download URL: parsextract-0.1.10.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
512b5d1dff16e8ef0117072be19418ae837bc765c6d4578f5ee46ac037c814e3
|
|
| MD5 |
e1f84d5c61c138d6406e18b02ecd0c37
|
|
| BLAKE2b-256 |
9fd3096ff42084cab7186849dcf6959ed712a56500a511df5e3c1f02e4c26312
|
File details
Details for the file parsextract-0.1.10-py3-none-any.whl.
File metadata
- Download URL: parsextract-0.1.10-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b93e1f460fc176492ef233c80cb40b4fb64e5458f4e79a82419931d75d57a610
|
|
| MD5 |
ff45c13eb78fa8051adae89dc4441892
|
|
| BLAKE2b-256 |
26791b43423cd57ef5eb530934807243f5d5044bda2b5a405e6747ce33542061
|