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'))
posted @ 2024-09-14 14:09  vx_guanchaoguo0  阅读(321)  评论(0)    收藏  举报