-
-
Notifications
You must be signed in to change notification settings - Fork 31
Examples
fastily edited this page Jul 30, 2018
·
9 revisions
- Clone the starter pack with
git clone https://github.com/fastily/jwiki-starter.git
- Make changes to
JwikiExample.java
undersrc/main/java/jwikistarter/
- Run your code with
./gradlew run
- ACTIONS (change Wiki content)
- QUERIES (read Wiki content)
- MULTI QUERIES (read Wiki content from multiple pages at once)
// Logs in to the English Wikipedia (you must have an account for this to work).
wiki.login("<YOUR_USERNAME>", "<YOUR_PASSWORD>")
// Test edits Wikipedia:Sandbox.
wiki.edit("Wikipedia:Sandbox", "Some test text", "Edit Summary");
// Uploads a file. You need to have an autoconfirmed/confirmed account and be logged in.
wiki.upload(Paths.get("<PATH_TO_YOUR_TEST_FILE>"), "<TITLE_TO_UPLOAD_FILE_TO>", "This is a test", "test summary");
// Gets the text of the main page and prints it.
System.out.println( wiki.getPageText("Main Page") );
// Gets the author of the Main Page and prints it
System.out.println( wiki.getPageCreator("Main Page") );
// Gets the categories on the Main Page and prints them
System.out.println( wiki.getCategoriesOnPage("Main Page") );
// Gets all wiki-links on a page (GitHub) and prints them
System.out.println( wiki.getLinksOnPage("GitHub") );
// Gets all wiki-links pointing to the the Stack Overflow page and prints them
System.out.println( wiki.whatLinksHere("Stack Overflow") );
// Check if a page (GitHub) exists and print true/false.
System.out.println( wiki.exists("GitHub") );
// Gets the first paragraph of the Stack Overflow page and prints it.
System.out.println( wiki.getTextExtract("Stack Overflow") );
// Gets 5 random articles (main namespace) on Wikipedia and print the result.
System.out.println( wiki.getRandomPages(5, NS.MAIN) );
// Check if the following pages exist, and then prints the ones that do.
System.out.println( MQuery.exists(wiki, true, FL.toSAL("Stack Overflow", "BlahBlahBlahDoesNotExist", "Main Page")) );
// Gets page text of GitHub, Foobar, and Apple Inc.
System.out.println( MQuery.getPageText(wiki, FL.toSAL("GitHub", "Foobar", "Apple Inc.")) );