📄 page_summary.py.obsolete
字号:
#! /usr/bin/env python################################################################################ ## Copyright 2005 University of Cambridge Computer Laboratory. ## ## This file is part of Nprobe. ## ## Nprobe is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## Nprobe is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Nprobe; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## ################################################################################from sys import argvimport getoptimport osimport sysfrom np_TCPConn import D_BIGDELscriptname = os.path.basename(argv[0])ofnm = Nonetry: optlist, args = getopt.getopt(sys.argv[1:], 'o:')except getopt.error, s: print '%s: %s' % (scriptname, s) usage(scriptname) sys.exit(1)for opt in optlist: if opt[0] == '-o': ofnm = opt[1]urld = {}nurl = 0totpages = 0nobs = 0bads = 0basedir = os.path.dirname(args[0])print 'files from', basedir, ':'for fnm in args: print os.path.basename(fnm) f = open(fnm, 'r') for l in f.readlines(): l = l.replace('\n', '') try: stuff = l.split(' ') ln = len(stuff) if ln != 6 and ln != 9: # probably a URL with a space l2 = l.replace(' ', '', 1) stuff = l2.split(' ') url, ntimes, dflags, no, totdur, tot85dur = stuff[:6] if len(stuff) == 8: durlessdel, dur85lessdel = stuff[6:] else: durlessdel = totdur dur85lessdel = tot85dur nt = int(ntimes) #if urld.has_key(url): #print 'whoops', url e = urld.setdefault(url, []) dl = (int(totdur)-int(durlessdel))/nt dl85 = (int(tot85dur)-int(dur85lessdel))/nt e.append((dl, dl85)) totpages += nt nobs += int(no) #print totdur, durlessdel, tot85dur, dur85lessdel except: #print 'l1 =', l #print 'l2 = ', l2 #raise bads += 1nurl = len(urld)## if not ofnm:## ofnm = raw_input('output dir? - base is %s' % (basedir))## outfnm = os.path.join(basedir, ofnm)## print 'writing to', outfnm## f = open(outfnm, 'w')## write = f.write## i = 1## for ps in urld.values():## for e in ps:## write('%d %d\n' % (i, e[0]))## i += 1print '%d pages %d page downloads %d obs (%d bad urls)' % (nurl, totpages, nobs, bads)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -