JWBF

Java Wiki Bot Framework - A Wiki helper

License

License

Categories

Categories

Net
GroupId

GroupId

net.sourceforge
ArtifactId

ArtifactId

jwbf
Last Version

Last Version

3.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

JWBF
Java Wiki Bot Framework - A Wiki helper
Project URL

Project URL

http://jwbf.sourceforge.net/
Source Code Management

Source Code Management

https://github.com/eldur/jwbf

Download jwbf

How to add to project

<!-- https://jarcasting.com/artifacts/net.sourceforge/jwbf/ -->
<dependency>
    <groupId>net.sourceforge</groupId>
    <artifactId>jwbf</artifactId>
    <version>3.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.sourceforge/jwbf/
implementation 'net.sourceforge:jwbf:3.1.1'
// https://jarcasting.com/artifacts/net.sourceforge/jwbf/
implementation ("net.sourceforge:jwbf:3.1.1")
'net.sourceforge:jwbf:jar:3.1.1'
<dependency org="net.sourceforge" name="jwbf" rev="3.1.1">
  <artifact name="jwbf" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.sourceforge', module='jwbf', version='3.1.1')
)
libraryDependencies += "net.sourceforge" % "jwbf" % "3.1.1"
[net.sourceforge/jwbf "3.1.1"]

Dependencies

compile (11)

Group / Artifact Type Version
org.jdom : jdom2 jar 2.0.5
com.fasterxml.jackson.core : jackson-core jar 2.4.3
com.fasterxml.jackson.core : jackson-databind jar 2.4.3
org.apache.httpcomponents : httpclient jar 4.3.4
org.apache.httpcomponents : fluent-hc jar 4.3.4
org.apache.httpcomponents : httpmime jar 4.3.4
org.apache.commons : commons-lang3 jar 3.3.2
org.slf4j : slf4j-api jar 1.7.7
javax.inject : javax.inject jar 1
com.google.guava : guava jar 18.0
com.google.code.findbugs : jsr305 jar 3.0.0

test (11)

Group / Artifact Type Version
junit : junit jar 4.11
com.google.inject : guice jar 3.0
org.mockito : mockito-all jar 1.10.8
com.github.dreamhead : moco-core jar 0.9.2
com.typesafe : config jar 1.2.1
org.jacoco : org.jacoco.agent jar 0.7.2.201409121644
ch.qos.logback : logback-classic jar 1.1.2
org.eclipse.jetty : jetty-server jar 9.3.0.M0
org.eclipse.jetty : jetty-servlet jar 9.3.0.M0
joda-time : joda-time jar 2.5
com.google.jimfs : jimfs jar 1.0

Project Modules

There are no modules declared in this project.

JWBF - JavaWikiBotFramework.

Build Status Coverage Status Maven Central

The Java Wiki Bot Framework is a library to retrieve data from and maintain MediaWiki-based wikis such as Wikipedia. It has packages that handle basic tasks (login, cookies, encoding, token management) so that you can write your wiki bot without being a MediaWiki API expert. JWBF requires JRE 1.7.

Code sample

  /**
   * Sample bot that retrieves and edits an article.
   */
  public static void main(String[] args) {
    MediaWikiBot wikiBot = new MediaWikiBot("https://en.wikipedia.org/w/");
    Article article = wikiBot.getArticle("42");
    System.out.println(article.getText().substring(5, 42));
    // HITCHHIKER'S GUIDE TO THE GALAXY FANS
    applyChangesTo(article);
    wikiBot.login("user", "***");
    article.save();
  }

  static void applyChangesTo(Article article) {
    // edits the article...
  }

Table of contents

Code sample | Developer resources | Getting started | Dependencies | Working with Wikimedia | More resources

Developer resources

Getting started

JWBF uses Maven to automatically resolve dependencies. To use Maven to start a new project, follow the Maven in Five Minutes tutorial. For a more detailed introduction, see Maven's Getting Started guide.

The Java Wiki Bot Framework is available from two repositories. For a more stable version of JWBF, use the most recent version in the RELEASES repository at Maven Central. For the development version, which will be most up-to-date, use the most recent version in the SNAPSHOTS repository at oss.sonatype.org.

Dependencies

Once you have started your project in Maven and have a pom.xml file for your bot's project, add the appropriate JWBF dependency to the <dependencies> section. When you build your project, JWBF and its own dependencies will be downloaded automatically.

Beginning with jwbf 4.x.x Java 8 is required

From RELEASES:

<dependency>
  <groupId>net.sourceforge</groupId>
  <artifactId>jwbf</artifactId>
  <version>3.1.1</version>
</dependency>

If you want to use a different release of JWBF, find your desired version in RELEASES and change <version> to its listed title.

From SNAPSHOTS:

Add this to your <repositories> section:

<repository>
  <id>sonatype-nexus-snapshots</id>
  <name>Sonatype Nexus Snapshots</name>
  <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>

Add this to your <dependencies> section:

<dependency>
  <groupId>net.sourceforge</groupId>
  <artifactId>jwbf</artifactId>
  <version>4.0.0-SNAPSHOT</version>
</dependency>

If you want to use a different snapshot of JWBF, find your desired version in SNAPSHOTS and change <version> to its listed title.

Examples

Here is one example of using JWBF to write a bot that can retrieve and edit an article on a desired wiki.

More Java examples (e.g. for queries) can be found at unit- and integration-test packages.

Working with Wikimedia

If you are working with Wikimedia sites, set an informative User-Agent header, because all Wikimedia sites require a HTTP User-Agent header for all requests.

//Creating a new MediaWikiBot with an informative user agent
HttpActionClient client = HttpActionClient.builder() //
  .withUrl("https://en.wikipedia.org/w/") //
  .withUserAgent("BotName", "1.0", "your Email or Maintainer UserName") //
  .withRequestsPerUnit(10, TimeUnit.MINUTES) //
  .build();
MediaWikiBot wikiBot = new MediaWikiBot(client);

See also

Versions

Version
3.1.1
3.1.0
3.0.0
2.1.0
2.0.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2-186