download file save to given path from given url wrapped for map function
(args)
| 484 | |
| 485 | |
| 486 | def download_one_file(args) -> str: |
| 487 | """ |
| 488 | download file save to given path from given url |
| 489 | wrapped for map function |
| 490 | """ |
| 491 | |
| 492 | (url, save_path, json_headers) = args |
| 493 | if json_headers is not None: |
| 494 | filebytes = get_html(url, return_type='content', json_headers=json_headers['headers']) |
| 495 | else: |
| 496 | filebytes = get_html(url, return_type='content') |
| 497 | if isinstance(filebytes, bytes) and len(filebytes): |
| 498 | with save_path.open('wb') as fpbyte: |
| 499 | if len(filebytes) == fpbyte.write(filebytes): |
| 500 | return str(save_path) |
| 501 | |
| 502 | |
| 503 | def parallel_download_files(dn_list: typing.Iterable[typing.Sequence], parallel: int = 0, json_headers=None): |