How to get filename from Content-Disposition in headers
First get the value of the header by using mechanize, then parse the header using the builtin cgi module. To demonstrate: >>> import mechanize >>> browser = mechanize.Browser() >>> response = browser.open(‘http://example.com/your/url’) >>> info = response.info() >>> header = info.getheader(‘Content-Disposition’) >>> header ‘attachment; filename=myfilename.txt’ The header value can then be parsed: >>> import cgi >>> … Read more