Commit d01ae530 authored by liyang's avatar liyang

feat:ins爬虫数据条件过滤优化

parent 2ffcf5d2
import requests import requests
import os import os
def download_image(url, save_path): def download_image(url, save_path):
""" """
下载图片并保存到本地文件 下载图片并保存到本地文件
...@@ -12,7 +13,9 @@ def download_image(url, save_path): ...@@ -12,7 +13,9 @@ def download_image(url, save_path):
if os.path.exists(save_path): if os.path.exists(save_path):
# print(f"图片文件已存在:{save_path}") # print(f"图片文件已存在:{save_path}")
return True return True
response = requests.get(url, stream=True) response = requests.get(url, stream=True)
if response.status_code == 200: if response.status_code == 200:
with open(save_path, 'wb') as file: with open(save_path, 'wb') as file:
for chunk in response.iter_content(1024): for chunk in response.iter_content(1024):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment