python写的一个squid访问日志分析的小程序

2019-10-05 19:51:29丽君

    parser.add_option('-i','--ip',dest="ip",action = "store_true",help="print ip information of access log")
    parser.add_option('-u','--url',dest="url",action = "store_true",help="print url information of access log")
    parser.add_option('-r','--reverse',action = "store_true",dest="reverse",help="reverse output ")
    (options,args) = parser.parse_args()
 
    if len(sys.argv) < 2:
        parser.print_help()
    if options.ip and options.url:
         parser.error(' -i and -u  can not be execute at the same time ')
    if options.ip :
        log_sort("ip", options.number , True and options.reverse  or False)
    if options.url:
        log_sort("url", options.number , True and  options.reverse or False)
 
    f.close()

效果如下: