python 爬取煎蛋网图片
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 爬取煎蛋网图片相关的知识,希望对你有一定的参考价值。
__author__ = mkdir(path): os path = path.strip() path = path.rstrip() mkfile = os.path.exists(path) mkfile: () : os.makedirs(path) () urllib, urllib2, re geturl(url): file_lists = [] req = urllib2.Request(url) req.add_header(, ) data = urllib2.urlopen(req) f = data.read() img = re.compile(, re.S) file_list = re.findall(img, f) f_list file_list: : f_url = f_list.index() f_url: file_li = f_list[f_list.index():f_url + ] file_lists.append(file_li) e: (e.message) file_lists save_file(path, url): mkdir(path) url_list = geturl(url) url_i url_list: req = urllib2.Request(url_i) req.add_header(, ) data = urllib2.urlopen(req) data_picture = data.read() path_pic = path + + url_i[-:] (path_pic, ) f: f.write(data_picture) f.flush() __name__ == : path = url = save_file(path, url)
本文出自 “时空旅行者” 博客,请务必保留此出处http://siweilai.blog.51cto.com/9233507/1774438
以上是关于python 爬取煎蛋网图片的主要内容,如果未能解决你的问题,请参考以下文章