Download the file from the provided URL. Use the filename in the URL as the name of the outputed file.
(logger, url, save_location)
| 73 | |
| 74 | |
| 75 | def download_file(logger, url, save_location): |
| 76 | """ |
| 77 | Download the file from the provided URL. |
| 78 | Use the filename in the URL as the name of the outputed file. |
| 79 | """ |
| 80 | local_filename = save_location + url.split("/")[-1] |
| 81 | logger.debug(local_filename) |
| 82 | # NOTE the stream=True parameter |
| 83 | req = requests.get(url, stream=True) |
| 84 | with open(local_filename, "wb") as out_f: |
| 85 | for chunk in req.iter_content(chunk_size=1024): |
| 86 | if chunk: # filter out keep-alive new chunks |
| 87 | out_f.write(chunk) |
| 88 | out_f.close() |
| 89 | return local_filename |
| 90 | |
| 91 | |
| 92 | def check_zones(domain, zones): |