I\'m using the Python requests lib to get a PDF file from the web. This works fine, but I now also want the original filename. If I go to a PDF file in Firefox and click
It is specified in an http header content-disposition. So to extract the name you would do:
content-disposition
import re d = r.headers['content-disposition'] fname = re.findall("filename=(.+)", d)[0]
Name extracted from the string via regular expression (re module).
re