If I have a URL that, when submitted in a web browser, pops up a dialog box to save a zip file, how would I go about catching and downloading this zip file in Python?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Most people recommend using
requestsif it is available, and therequestsdocumentation recommends this for downloading and saving raw data from a url:Since the answer asks about downloading and saving the zip file, I haven’t gone into details regarding reading the zip file. See one of the many answers below for possibilities.
If for some reason you don’t have access to
requests, you can useurllib.requestinstead. It may not be quite as robust as the above.Finally, if you are using Python 2 still, you can use
urllib2.urlopen.