web信息收集脚本
From:Joseph#! /usr/bin/python
# -*- coding: utf-8 -*-
# Joseph
import os
import re
import urllib
def getFileName(rootpath,path):
''' 获取指定目录下的所有指定后缀的文件名 '''
f_list = os.listdir(path)
for i in f_list:
# os.path.splitext():分离文件名与扩展名
if os.path.splitext(i) == '.php' or os.path.splitext(i) == '.txt' or os.path.splitext(i) == '.xls' or os.path.splitext(i) == '.rar':
Absolutepath=urllib.quote(path+i)
scandir=re.sub(rootpath,"",Absolutepath)
print urllib.unquote("/"+scandir)
def processDirectory(rootpath,dirname):
Filelist=os.listdir(dirname)
getFileName(rootpath,dirname)
for files in Filelist:
if os.path.isdir(dirname+files):
processDirectory(rootpath,dirname+files+"/")
pass
pass
def main(path):
rootpath=urllib.quote(path)
processDirectory(rootpath,path)
pass
if __name__ == '__main__':
scandir=raw_input('Please input startdir:')
main(scandir+"/") 续爷这个脚本只是一个雏形,期待更多的人来添加功能 前排瞻仰大牛!!! 学习一下 看看是怎么写的
页:
[1]