Package info.bliki.api

Examples of info.bliki.api.User


      }
    }
  }

  public static void testQueryXML001() {
    User user = new User("", "", "http://en.wikipedia.org/w/api.php");
    user.login();
    String[] valuePairs = { "list", "allpages", "apfrom", "B", "aplimit", "20" };
    Connector connector = new Connector();
    String responseBody = connector.queryXML(user, valuePairs);
    if (responseBody == null) {
      System.out.println("Got no XML result for the query");
View Full Code Here


  }

  public static void testWikipediaENAPI(String title, String apiLink) {
    String[] listOfTitleStrings = { title };
    String titleURL = Encoder.encodeTitleLocalUrl(title);
    User user = new User("", "", apiLink);
    user.login();
    String mainDirectory = "c:/temp/";
    // the following subdirectory should not exist if you would like to create a
    // new database
    String databaseSubdirectory = "WikiDB";
    // the following directory must exist for image downloads
View Full Code Here

    super();
  }

  public static void testQueryContent001() {
    String[] listOfTitleStrings = { "Main Page", "API" };
    User user = new User("", "", "http://meta.wikimedia.org/w/api.php");
    user.login();
    List<Page> listOfPages = user.queryContent(listOfTitleStrings);
    for (Page page : listOfPages) {
      // print page information
      System.out.println(page.getCurrentContent());
    }
  }
View Full Code Here

  public static void testQueryContent002() {
    WikiModel wikiModel = new WikiModel("http://en.wikipedia.org/wiki/${image}", "http://en.wikipedia.org/wiki/${title}");
    wikiModel.setUp();
    String[] listOfTitleStrings = { "Tom Hanks" };
    User user = new User("", "", "http://en.wikipedia.org/w/api.php");
    user.login();
    List<Page> listOfPages = user.queryContent(listOfTitleStrings);
    for (Page page : listOfPages) {
      String renderedHTML = wikiModel.render(page.getCurrentContent());
      System.out.println(renderedHTML);
      break;
    }
View Full Code Here

    }
  }

  public static void testQueryLinks001() {
    String[] listOfTitleStrings = { "Main Page", "API" };
    User user = new User("", "", "http://meta.wikimedia.org/w/api.php");
    user.login();
    List<Page> listOfPages = user.queryLinks(listOfTitleStrings);
    for (Page page : listOfPages) {
      // print page information
      System.out.println(page.toString());
      for (int j = 0; j < page.sizeOfLinksList(); j++) {
        Link link = page.getLink(j);
View Full Code Here

    }
  }

  public static void testQueryCategories001() {
    String[] listOfTitleStrings = { "Main Page", "API" };
    User user = new User("", "", "http://meta.wikimedia.org/w/api.php");
    user.login();
    List<Page> listOfPages = user.queryCategories(listOfTitleStrings);
    for (Page page : listOfPages) {
      // print page information
      System.out.println(page.toString());
      for (int j = 0; j < page.sizeOfCategoryList(); j++) {
        Category cat = page.getCategory(j);
View Full Code Here

    }
  }

  public static void testQueryImageinfo001() {
    String[] listOfImageStrings = { "Image:Question book-new.svg", "Image:Test.jpg", "Image:Brandenburger Tor Blaue Stunde.jpg" };
    User user = new User("", "", "http://en.wikipedia.org/w/api.php");
    user.login();
    List<Page> listOfPages = user.queryImageinfo(listOfImageStrings);
    for (Page page : listOfPages) {
      // print page information
      System.out.println(page.toString());
      // download the image to c:\temp directory
      FileOutputStream os = null;
View Full Code Here

    }

    private static void testWikipediaENAPI(String title) {
        String[] listOfTitleStrings = { title };
        String titleURL = Encoder.encodeTitleLocalUrl(title);
        User user = new User("", "", "http://en.wikipedia.org/w/api.php");
        user.login();
        WikiDB db = null;
        String mainDirectory = "c:/temp/";
        // the following subdirectory should not exist if you would like to create a
        // new database
        String databaseSubdirectory = "WikiDB";
View Full Code Here

    private static void testWikipediaENAPI(String title) throws Exception {
        String articleAddress = "http://en.wikipedia.org/w/api.php?action=query&titles=" + Encoder.encodeTitleToUrl(title, true)
                + "&prop=revisions&rvprop=content&format=xml";
        String articleWikiContent = loadRAWContent(articleAddress);

        User wikiUser = new User("", "", "http://en.wikipedia.org/w/api.php");
        wikiUser.login();

        // set up a simple cache for this example. HashMap is not usable for
        // production! Use something like http://ehcache.org for production!
        Map<String, String> contentCache = new HashMap<>(2000);
        APIWikiModelInMemory wikiModel = new APIWikiModelInMemory(wikiUser, Locale.ENGLISH, "${image}", "${title}", contentCache);
View Full Code Here

    }

    public static void testWikipediaENAPI(String title) {
        String[] listOfTitleStrings = { title };
        String titleURL = Encoder.encodeTitleLocalUrl(title);
        User user = new User("", "", "http://en.wikipedia.org/w/api.php");
        user.login();
        String mainDirectory = "c:/temp/";
        // the following subdirectory should not exist if you would like to create a
        // new database
        String databaseSubdirectory = "WikiDB";
        // the following directory must exist for image downloads
View Full Code Here

TOP

Related Classes of info.bliki.api.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.