Suppose i have links as follows:
http://example.com/index.html
http://example.com/stack.zip
http://example.com/setup.exe
http://example.com/news/
In the above links first and fourth links are web page links and second and third are the file link.
These are only some examples of files links i.e .zip and .exe, but there may be many other files.
Is there any standard way to distinguish between file url or web page link? Thanks in advance.
Demo:
Output:
mytest.headers.items() is a list of tuples, you can see in my example that the last item in the list describes the content
I am not sure if the length varies so you could iterate through it to find the one that has 'content-type' in it.