Last active
December 17, 2015 17:59
-
-
Save kartben/5650228 to your computer and use it in GitHub Desktop.
eclipse wiki edition stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.wikipedia; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.text.DateFormat; | |
import java.util.HashMap; | |
import java.util.Map; | |
import org.wikipedia.Wiki.Revision; | |
public class Main { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
try { | |
Map<String, String> pages = new HashMap<String, String>(); | |
Wiki wiki = new Wiki("wiki.eclipse.org"); | |
String[] toSearch = new String[] { "mihini", "koneki" }; | |
for (String term : toSearch) { | |
String[][] searchResult = wiki.search(term); | |
for (String[] result : searchResult) { | |
if (result[0].toLowerCase().contains(term)) { | |
pages.put(result[0], term); | |
} | |
} | |
} | |
PrintWriter writer = new PrintWriter( | |
"/Users/kartben/Documents/wiki.csv", "UTF-8"); | |
for (String page : pages.keySet()) { | |
Revision[] history = wiki.getPageHistory(page); | |
for (Revision rev : history) { | |
if (rev.getUser().contains("sierrawireless")) | |
continue; | |
StringBuffer line = new StringBuffer(); | |
line.append(pages.get(page)); | |
line.append(";"); | |
line.append(rev.getPage()); | |
line.append(";"); | |
line.append(rev.getUser()); | |
line.append(";"); | |
line.append(DateFormat.getDateInstance(DateFormat.SHORT) | |
.format(rev.getTimestamp().getTime())); | |
line.append(";"); | |
line.append(rev.getSize()); | |
System.out.println(line); | |
writer.println(line); | |
} | |
} | |
writer.close(); | |
} catch (IOException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment