pyurlextract is a Python library that extracts all possible links and redirections from any shortened URL. It helps in expanding short links to reveal their full URLs and potential redirections.
PyPI: https://pypi.org/project/pyurlextract/
Install the library using pip:
pip install pyurlextract
Here's how you can use pyurlextract to extract links from a shortened URL:
from pyurlextract import extract_shorturl
short_url = "link" # Replace with the actual short URL
full_link, all_links = extract_shorturl(short_url)
if full_link is None:
print("Failed to expand the URL")
print("Details:", all_links)
else:
print("Original URL:", short_url)
print("Full Link:", full_link)
print("All Possible Redirections:", all_links)
print(extract_shorturl(short_url))
short_url
(str): The shortened URL that needs to be expanded.
full_link
(str | None): The fully expanded URL orNone
if extraction fails.all_links
(list): A list of all possible redirections found.
Original URL: https://bit.ly/example
Full Link: https://example.com/page
All Possible Redirections: ['https://example.com/page', 'https://redirect.example.com']
- Expands shortened URLs from various services.
- Extracts all possible redirections from a given URL.
- Easy-to-use Python interface.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.