首页 > 代码库 > 将乌云漏洞图片下载到本地
将乌云漏洞图片下载到本地
#coding=utf-8 import MySQLdb import re import requests conn = MySQLdb.connect(host=‘127.0.0.1‘,user=‘root‘,passwd=‘123456‘,db=‘wooyunbugs‘,charset=‘utf8‘) cursor = conn.cursor() def q(): sql = ‘select * from `a`‘ cursor.execute(sql) for row in cursor.fetchall(): id = int(row[0]) print id, content1 = row[2] filenameList = f(content1) if len(filenameList)== 0: pass else: for imgUrl in filenameList: try: downloadImageFile(imgUrl) print ‘success‘ except: pass def f(c): re1 = re.compile(‘<img src="http://www.mamicode.com/(http://static.wooyun.org/wooyun/.*?)"‘) s = re1.findall(c) return s def downloadImageFile(imgUrl): local_filename = imgUrl.split(‘/‘)[-1] local_filedir = imgUrl.split(‘/‘)[-2] print "Download Image File=", local_filename r = requests.get(imgUrl, stream=True, timeout=20) dirName =local_filedir import os if not os.path.exists(dirName): os.makedirs(dirName) with open(dirName+‘/‘+local_filename, ‘wb‘) as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) f.flush() f.close() if __name__ == ‘__main__‘: q()
将乌云漏洞图片下载到本地
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。