public class MediaWikiBot extends Object implements WikiBot
MediaWikiBot b = new MediaWikiBot("http://yourwiki.org");
b.login("Username", "Password");
System.out.println(b.readContent("Main Page").getText());
How to find the correct wikiurl
The correct wikiurl is sometimes not easy to find, because some wikiadmis uses url rewriting
rules. In this cases the correct url is the one, which gives you access to api.php.
E.g. Compare
http://www.mediawiki.org/wiki/api.php http://www.mediawiki.org/w/api.phpThus the correct wikiurl is:
http://www.mediawiki.org/w/
| Modifier and Type | Field and Description |
|---|---|
static char[] |
INVALID_LABEL_CHARS
These chars are not allowed in article names.
|
| Constructor and Description |
|---|
MediaWikiBot()
use this constructor, if you want to work with IoC.
|
MediaWikiBot(HttpActionClient client) |
MediaWikiBot(String url) |
MediaWikiBot(URL u) |
MediaWikiBot(URL url,
boolean testHostReachable) |
| Modifier and Type | Method and Description |
|---|---|
void |
delete(String title) |
void |
delete(String title,
String reason)
deletes an article with a reason
|
Article |
getArticle(String name) |
Article |
getArticle(String name,
int properties) |
String |
getHostUrl() |
Siteinfo |
getSiteinfo() |
Userinfo |
getUserinfo() |
MediaWiki.Version |
getVersion() |
String |
getWikiType() |
boolean |
isEditApi() |
boolean |
isLoggedIn() |
void |
login(String username,
String passwd)
Performs a Login.
|
void |
login(String username,
String passwd,
String domain)
Performs a Login.
|
String |
performAction(ContentProcessable a) |
SimpleArticle |
readData(String name) |
SimpleArticle |
readData(String name,
int properties) |
void |
useEditApi(boolean useEditApi) |
void |
writeContent(SimpleArticle simpleArticle) |
public static final char[] INVALID_LABEL_CHARS
public MediaWikiBot()
public MediaWikiBot(URL u)
u - wikihosturl like "http://www.mediawiki.org/w/"public MediaWikiBot(HttpActionClient client)
public MediaWikiBot(String url)
url - wikihosturl like "http://www.mediawiki.org/w/"IllegalArgumentException - if param url does not represent a well-formed urlpublic MediaWikiBot(URL url, boolean testHostReachable)
url - wikihosturl like "http://www.mediawiki.org/w/"testHostReachable - if true, test if host reachablepublic void login(String username, String passwd, String domain)
username - the usernamepasswd - the passworddomain - login domain (Special for LDAPAuth extention to authenticate against LDAP users)PostLoginpublic void login(String username, String passwd)
#writeContent(ContentAccessable)public Article getArticle(String name, int properties)
name - of article in a mediawiki like "Main Page"properties - GetRevisionGetRevisionpublic SimpleArticle readData(String name, int properties)
public SimpleArticle readData(String name)
public Article getArticle(String name)
name - of article in a mediawiki like "Main Page"GetRevisionpublic void writeContent(SimpleArticle simpleArticle)
writeContent in interface WikiBotpublic final boolean isLoggedIn()
public Userinfo getUserinfo()
getUserinfo in interface WikiBotpublic String performAction(ContentProcessable a)
@Nonnull public MediaWiki.Version getVersion() throws IllegalStateException
IllegalStateException - if no version was found.getSiteinfo()@Nonnull public Siteinfo getSiteinfo()
Siteinfopublic boolean isEditApi()
public final void useEditApi(boolean useEditApi)
useEditApi - Set to false, to force editing without the API.public final String getWikiType()
getWikiType in interface WikiBotpublic String getHostUrl()
Copyright © 2013. All Rights Reserved.