curl 设置https 不验证证书
不验证证书减少交互
curl -k -f {$url} -o {dest_path}
python requests
def download_file_with_requests(url: str, file_path: str):
with Session() as session:
session.keep_alive = False
logger.debug(f"data_url:{url} file_path:{file_path} time:{time.strftime('%Y-%m-%d %H:%M:%S')}")
try:
with session.get(url, verify=False, timeout=(5,120)) as response:
response.raise_for_status()
with open(file_path, 'wb') as file:
file.write(response.content)
except requests.exceptions.RequestException as e:
logger.error(f"File {file_path} download fail ,error:{e}.")
raise FileNotDownloadError(f"Curl download failed: {e}")
logger.debug(time.strftime('%Y-%m-%d %H:%M:%S'))
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/18413844