标签:request size 技术分享 pre ges os.path 保存 bsp pen
import requests import os url="http://lofter.nos.netease.com/sogou-Y1gxMDFIeFVHeWhCTkZaMEkzYWx1bGR5WEszQTdRTEZPcndxZWo3Q0dwTG1iZF9uVENpM0tCaUJNOXA1bmZkTA.jpg" root="F://pics//"; 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) with open(path,'wb') as f: f.write(r.content) f.close() print("图片保存cg") else: print("保存失败") except: print('爬取失败')2、在windows终端执行以上代码
标签:request size 技术分享 pre ges os.path 保存 bsp pen
原文地址:http://blog.51cto.com/12831900/2067623