So I am making this downloader app in python using tkinter and urllib.request and I want to give the user the option to have the file downloaded with default name and extension. And I know that there are MILLIONS of tutorials out there on how to do this, but my problem is with this specific URL: https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcR9JHQ-y1AyCjkJt3gl0jTtNtQdhv0lCdDYxqnc2wY9zy_hSOSy I have tried many codes like wget and urlparse but none of them were able to get the extension of this file from its URL. So is there any other way? The wget command:
url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcR9JHQ-y1AyCjkJt3gl0jTtNtQdhv0lCdDYxqnc2wY9zy_hSOSy'
test = wget.detect_filename(url)
print(test)
The output with the mentioned URL:
images
The urllib.parse command:
url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcR9JHQ-y1AyCjkJt3gl0jTtNtQdhv0lCdDYxqnc2wY9zy_hSOSy'
path = urllib.parse.urlparse(url).path
ext = os.path.splitext(path)[1]
print(path)
print(ext)
The output with the mentioned URL:
/images
Is there something wrong with the URL?