eurlparser


Nameeurlparser JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/keklick1337/eurlparser
SummaryA powerful URL parser with detailed analysis.
upload_time2024-08-09 13:02:13
maintainerNone
docs_urlNone
authorVladislav Tislenko
requires_python>=3.6
licenseMIT
keywords url parser url-parser enhanced-url-parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Enhanced URL Parser

A powerful URL parser with detailed analysis.

## Features

- Parse URLs into components like protocol, host, path, query, and fragment.
- Supports both IPv4 and IPv6 addresses.
- Handles URLs with or without protocols.
- Reconstruct the URL from parsed components.

## Installation

```bash
pip install eurlparser
```

## Usage
Here's how to use the `EnhancedURLParser` class to parse and analyze URLs.

## Basic Example
```python
from eurlparser import EnhancedURLParser

# Example URL
url = "https://user:password@www.example.com:8080/path/to/resource?query=python&foo=bar#section"

# Initialize the parser
parser = EnhancedURLParser(url)

# Access different components
print("Protocol:", parser.protocol)            # Output: https
print("Username:", parser.username)            # Output: user
print("Password:", parser.password)            # Output: password
print("Host:", parser.host)                    # Output: www.example.com
print("Port:", parser.port)                    # Output: 8080
print("Path:", parser.path)                    # Output: /path/to/resource
print("Query:", parser.query)                  # Output: {'query': ['python'], 'foo': ['bar']}
print("Fragment:", parser.fragment)            # Output: section

# Reconstruct the URL
reconstructed_url = parser.get_fixed_url()
print("Reconstructed URL:", reconstructed_url)
# Output: https://user:password@www.example.com:8080/path/to/resource?query=python&foo=bar#section

# Get a structured dictionary of the URL components
url_structure = parser.get_url_structure()
print("URL Structure:", url_structure)
```

## Handling URLs Without Protocol
```python
from eurlparser import EnhancedURLParser

# Example URL without protocol
url = "/www.example.com/path/to/resource?query=python"

# Initialize the parser
parser = EnhancedURLParser(url)

# Access components
print("Host:", parser.host)                    # Output: www.example.com
print("Path:", parser.path)                    # Output: /path/to/resource
print("Query:", parser.query)                  # Output: {'query': ['python']}

# Reconstruct the URL (defaults to path '/')
reconstructed_url = parser.get_fixed_url()
print("Reconstructed URL:", reconstructed_url)
# Output: www.example.com/path/to/resource?query=python
```

## Parsing and Handling IPv6 Addresses
```python
from eurlparser import EnhancedURLParser

# Example URL with IPv6 address
url = "http://[2001:db8::1]:8080/path?query=value"

# Initialize the parser
parser = EnhancedURLParser(url)

# Access components
print("Protocol:", parser.protocol)            # Output: http
print("Host:", parser.host)                    # Output: 2001:db8::1
print("Port:", parser.port)                    # Output: 8080
print("Path:", parser.path)                    # Output: /path
print("Query:", parser.query)                  # Output: {'query': ['value']}

# Reconstruct the URL
reconstructed_url = parser.get_fixed_url()
print("Reconstructed URL:", reconstructed_url)
# Output: http://[2001:db8::1]:8080/path?query=value
```

# Handling Invalid or Unusual URLs
```python
from eurlparser import EnhancedURLParser

# Example of an invalid protocol in the URL
url = "ht@tp://example.com/path"

# Initialize the parser
parser = EnhancedURLParser(url)

# Access components
print("Host:", parser.host)                    # Output: example.com
print("Path:", parser.path)                    # Output: /path
print("Protocol:", parser.protocol)            # Output: None (invalid protocol)

# Even with unusual inputs, the URL can be reconstructed correctly:
reconstructed_url = parser.get_fixed_url()
print("Reconstructed URL:", reconstructed_url)
# Output: example.com/path
```

## Contribution
Feel free to contribute to the project by forking the repository and creating pull requests. If you encounter any issues or have suggestions, please open an issue on GitHub.

## License
This project is licensed under the MIT License. See the LICENSE file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/keklick1337/eurlparser",
    "name": "eurlparser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "url, parser, url-parser, enhanced-url-parser",
    "author": "Vladislav Tislenko",
    "author_email": "Vladislav Tislenko <keklick1337@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/7c/aa/0c22e88b4862160058b1c22ae0e2cd347fb8de9afe6f61b79ca9b7f34d7e/eurlparser-0.0.2.tar.gz",
    "platform": null,
    "description": "# Enhanced URL Parser\n\nA powerful URL parser with detailed analysis.\n\n## Features\n\n- Parse URLs into components like protocol, host, path, query, and fragment.\n- Supports both IPv4 and IPv6 addresses.\n- Handles URLs with or without protocols.\n- Reconstruct the URL from parsed components.\n\n## Installation\n\n```bash\npip install eurlparser\n```\n\n## Usage\nHere's how to use the `EnhancedURLParser` class to parse and analyze URLs.\n\n## Basic Example\n```python\nfrom eurlparser import EnhancedURLParser\n\n# Example URL\nurl = \"https://user:password@www.example.com:8080/path/to/resource?query=python&foo=bar#section\"\n\n# Initialize the parser\nparser = EnhancedURLParser(url)\n\n# Access different components\nprint(\"Protocol:\", parser.protocol)            # Output: https\nprint(\"Username:\", parser.username)            # Output: user\nprint(\"Password:\", parser.password)            # Output: password\nprint(\"Host:\", parser.host)                    # Output: www.example.com\nprint(\"Port:\", parser.port)                    # Output: 8080\nprint(\"Path:\", parser.path)                    # Output: /path/to/resource\nprint(\"Query:\", parser.query)                  # Output: {'query': ['python'], 'foo': ['bar']}\nprint(\"Fragment:\", parser.fragment)            # Output: section\n\n# Reconstruct the URL\nreconstructed_url = parser.get_fixed_url()\nprint(\"Reconstructed URL:\", reconstructed_url)\n# Output: https://user:password@www.example.com:8080/path/to/resource?query=python&foo=bar#section\n\n# Get a structured dictionary of the URL components\nurl_structure = parser.get_url_structure()\nprint(\"URL Structure:\", url_structure)\n```\n\n## Handling URLs Without Protocol\n```python\nfrom eurlparser import EnhancedURLParser\n\n# Example URL without protocol\nurl = \"/www.example.com/path/to/resource?query=python\"\n\n# Initialize the parser\nparser = EnhancedURLParser(url)\n\n# Access components\nprint(\"Host:\", parser.host)                    # Output: www.example.com\nprint(\"Path:\", parser.path)                    # Output: /path/to/resource\nprint(\"Query:\", parser.query)                  # Output: {'query': ['python']}\n\n# Reconstruct the URL (defaults to path '/')\nreconstructed_url = parser.get_fixed_url()\nprint(\"Reconstructed URL:\", reconstructed_url)\n# Output: www.example.com/path/to/resource?query=python\n```\n\n## Parsing and Handling IPv6 Addresses\n```python\nfrom eurlparser import EnhancedURLParser\n\n# Example URL with IPv6 address\nurl = \"http://[2001:db8::1]:8080/path?query=value\"\n\n# Initialize the parser\nparser = EnhancedURLParser(url)\n\n# Access components\nprint(\"Protocol:\", parser.protocol)            # Output: http\nprint(\"Host:\", parser.host)                    # Output: 2001:db8::1\nprint(\"Port:\", parser.port)                    # Output: 8080\nprint(\"Path:\", parser.path)                    # Output: /path\nprint(\"Query:\", parser.query)                  # Output: {'query': ['value']}\n\n# Reconstruct the URL\nreconstructed_url = parser.get_fixed_url()\nprint(\"Reconstructed URL:\", reconstructed_url)\n# Output: http://[2001:db8::1]:8080/path?query=value\n```\n\n# Handling Invalid or Unusual URLs\n```python\nfrom eurlparser import EnhancedURLParser\n\n# Example of an invalid protocol in the URL\nurl = \"ht@tp://example.com/path\"\n\n# Initialize the parser\nparser = EnhancedURLParser(url)\n\n# Access components\nprint(\"Host:\", parser.host)                    # Output: example.com\nprint(\"Path:\", parser.path)                    # Output: /path\nprint(\"Protocol:\", parser.protocol)            # Output: None (invalid protocol)\n\n# Even with unusual inputs, the URL can be reconstructed correctly:\nreconstructed_url = parser.get_fixed_url()\nprint(\"Reconstructed URL:\", reconstructed_url)\n# Output: example.com/path\n```\n\n## Contribution\nFeel free to contribute to the project by forking the repository and creating pull requests. If you encounter any issues or have suggestions, please open an issue on GitHub.\n\n## License\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A powerful URL parser with detailed analysis.",
    "version": "0.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/keklick1337/eurlparser/issues",
        "Homepage": "https://github.com/keklick1337/eurlparser"
    },
    "split_keywords": [
        "url",
        " parser",
        " url-parser",
        " enhanced-url-parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4d83e73526336a9ec2d57d770d3e8e4b76990b98b963c29d7e392df1427c747",
                "md5": "673b402bc3f8238e84241eab2ce935b4",
                "sha256": "f1bd379d8a20f712f9079776dd1b6eeb88638ceff69bf3254d1195184b555fa2"
            },
            "downloads": -1,
            "filename": "eurlparser-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "673b402bc3f8238e84241eab2ce935b4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5657,
            "upload_time": "2024-08-09T13:02:11",
            "upload_time_iso_8601": "2024-08-09T13:02:11.756403Z",
            "url": "https://files.pythonhosted.org/packages/a4/d8/3e73526336a9ec2d57d770d3e8e4b76990b98b963c29d7e392df1427c747/eurlparser-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7caa0c22e88b4862160058b1c22ae0e2cd347fb8de9afe6f61b79ca9b7f34d7e",
                "md5": "95da5307ffc35d14be26518f45c832d8",
                "sha256": "23c9d2eaeee906d4a4653002feb55396a04a1f19d0965d49e1fb5c8f70e67bf3"
            },
            "downloads": -1,
            "filename": "eurlparser-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "95da5307ffc35d14be26518f45c832d8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7305,
            "upload_time": "2024-08-09T13:02:13",
            "upload_time_iso_8601": "2024-08-09T13:02:13.148330Z",
            "url": "https://files.pythonhosted.org/packages/7c/aa/0c22e88b4862160058b1c22ae0e2cd347fb8de9afe6f61b79ca9b7f34d7e/eurlparser-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-09 13:02:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "keklick1337",
    "github_project": "eurlparser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "eurlparser"
}
        
Elapsed time: 0.29045s