'How to analyze/retrieve link details?

I'm trying to retrieve the URL details after I enter it. When I go to this URL https://entropystream.live/PLAIDARMY it is going to be reversed into this https://entropystream.live/not-found/PLAIDARMY/no-stream and this what I want. I want to get the next URL details (after conversion).

I tried using the following code but this can't get me the details after conversion:

from urllib.parse import urlparse

url = "https://entropystream.live/PLAIDARMY"
parts = urlparse(url)
print(parts)

output:

ParseResult(scheme='https', netloc='entropystream.live', path='/PLAIDARMY', params='', query='', fragment='')

I want to get the details after conversion so I can have "no-stream" in the output.



Solution 1:[1]

What you suggest as a "conversion", could be an HTTP redirect or a location rewrite done at the user agent level. You can only perform the parsing you want after you have the "final" URL, so you need to interact with the server.

In case of an HTTP redirect, you can use requests, as described here: Python Requests library redirect new url

In case of a location change at the user agent, you can use a tool like Selenium: https://selenium-python.readthedocs.io/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1