1, the picture crawling Code
import requests import os root = "H:/美图/" url = "https://k.zol-img.com.cn/sjbbs/7692/a7691501_s.jpg" path = root + url.split("/")[-1] try: if not os.path.exists(root): os.mkdir(root) if not os.path.exists(path): r = requests.get(url) r.raise_for_status() with open(path, "wb") as f: f.write(r.content) f.close() Print ( " File saved successfully " ) the else : Print ( " file already exists " ) the except : Print ( " crawling failure " )