zoukankan      html  css  js  c++  java
  • 将乌云漏洞图片下载到本地

    #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://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()
    

      

  • 相关阅读:
    可执行程序的装载
    stdafx.h的作用
    AI调色板
    3ds max输出图片
    3ds max移除几何体的线段
    3ds max删除了对象后,还是将原来所有对象输出的原因
    vs win32 & MFC 指针默认位置
    3ds max 分离对象
    PDF
    endnote设置文献第二行悬挂缩进办法
  • 原文地址:https://www.cnblogs.com/depycode/p/6003441.html
Copyright © 2011-2022 走看看