def download(self, url, save_path, header={}, redownload=False):
if save_path is None:<EOL><INDENT>logger.error("<STR_LIT>")<EOL>return None<EOL><DEDENT>header = self.get_headers()<EOL>if len(header) > <NUM_LIT:0>:<EOL><INDENT>header.update(header)<EOL><DEDENT>logger.debug("<STR_LIT>".format(url=url, save_path=save_path))<EOL>save_location = cutil.norm_path(save_path)<EOL>if redownload is False:<EOL><INDENT>if os.path.isfile(save_location):<EOL><INDENT>logger.debug("<STR_LIT>".format(save_location=save_location))<EOL>return save_location<EOL><DEDENT><DEDENT>cutil.create_path(save_location)<EOL>if url.startswith('<STR_LIT>'):<EOL><INDENT>url = "<STR_LIT>" + url<EOL><DEDENT>try:<EOL><INDENT>with urllib.request.urlopen(urllib.request.Request(url, headers=header)) as response,open(save_location, '<STR_LIT:wb>') as out_file:<EOL><INDENT>data = response.read()<EOL>out_file.write(data)<EOL><DEDENT><DEDENT>except urllib.error.HTTPError as e:<EOL><INDENT>save_location = None<EOL>if e.code != <NUM_LIT>:<EOL><INDENT>logger.exception("<STR_LIT>".format(url=url))<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>save_location = None<EOL>logger.exception("<STR_LIT>".format(url=url))<EOL><DEDENT>return save_location<EOL>
Currently does not use the proxied driver
TODO: Be able to use cookies just like headers is used here
:return: the path of the file that was saved