How to handle download pop up window using Python and get the file saved?
Question: I have a link, which contains downloadble file,now when i am putting that link
onto the browser, and hit `ENTER` a popup window is coming to download. Now
using Python can we save that file in local machine?

say downloadable link :

    
    
    https://xyz.test.com/aems/file/filegetrevision.do?fileEntityId=8120070&cs=LU31NT9us5P9Pvkb1BrtdwaCrEraskiCJcY6E2ucP5s.xyz
    

**Code**

it is for preparing the link: but finally i couldn't find a way how to handle
this:

    
    
    for a in soup.find_all('a', {"style": "display:inline; position:relative;"}, href=True):
        href = a['href'].strip()
        href = "https://xyz.test.com/" + href
    print(href)
    

[Download window](http://i.stack.imgur.com/5nIcZ.png)


Answer: If your intention is not to test the _download popup_ itself, but the
existence/content of the file, you can download it using urllib:

    
    
    import urllib
    urllib.urlretrieve(href, filename)
    

You would need to add the necesary exception handling (to make sure the URL
really points to something) and the file processing once downloaded to verify
it's content.

