import java.io.*; import java.util.*; /** * Description of the Class * * @author dav * @created July 4, 2004 */ public class AnalyzeRefererLog { /** * The main program for the AnalyzeRefererLog class * * @param args The command line arguments */ public static void main(String[] args) { if (args.length < 1) { System.out.println("need the full path/name of the combined referal log as param"); System.exit(0); } String log = args[0]; HashMap map = new HashMap(); try { File file = new File(log); BufferedReader in = new BufferedReader(new FileReader(file)); String line = in.readLine(); while (line != null) { String[] cols = line.split(" "); String post = cols[6]; // 7th column is the URL requested String referer = cols[10]; // 11th column is the referal URL //System.out.println(line); if (post.indexOf("archives") > -1 && post.indexOf("html") > -1) { if (!referer.equals("\"-\"") && !referer.equals("\"\"") && (referer.indexOf("google") == -1) && (referer.indexOf("search") == -1) && (referer.indexOf("altavista") == -1) && (referer.indexOf("msn.com") == -1) ) { //System.out.println("url: "+post); //System.out.println(" ref: "+referer); Set set = (Set) map.get(post); if (set == null) { set = new HashSet(); } set.add(referer); map.put(post, set); } } line = in.readLine(); } in.close(); } catch (Exception e) { e.printStackTrace(); } for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { String post = (String) it.next(); Set set = (Set) map.get(post); System.out.println("" + set.size() + " post: " + post); for (Iterator it2 = set.iterator(); it2.hasNext(); ) { System.out.println(" + " + it2.next()); } } } }