Crates.io | mwbot |
lib.rs | mwbot |
version | |
source | src |
created_at | 2021-10-14 04:31:08.177567 |
updated_at | 2024-11-23 15:01:38.023928 |
description | A MediaWiki bot framework |
homepage | https://www.mediawiki.org/wiki/mwbot-rs |
repository | https://gitlab.wikimedia.org/repos/mwbot-rs/mwbot/ |
max_upload_size | |
id | 464785 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A MediaWiki bot and tool framework
mwbot
aims to provide a batteries-included framework for building bots
and tools for MediaWiki wikis. It builds on top of the mwapi
and parsoid crates, which offer lower-level APIs.
Create a ~/.config/mwbot.toml
file with the following structure:
wiki_url = "https://en.wikipedia.org/w/"
If want to authenticate, add an auth section:
[auth]
username = "Example"
oauth2_token = "[...]"
See the OAuth documentation for how to get an OAuth 2 token. Using an owner-only consumer is the easiest way to do so.
let bot = mwbot::Bot::from_default_config().await.unwrap();
let page = bot.page("Rust (programming language)")?;
let html = page.html().await?.into_mutable();
// The lead section is the second p tag in the first section
let lead = html.select("section > p")[1].text_contents();
assert!(lead.starts_with("Rust is a multi-paradigm, general-purpose programming language"));
Using [Bot::from_default_config()
] will look in the current directory
for mwbot.toml
before looking in the user's config directory. A
custom path can be specified by using Bot::from_config(...)
.
let bot = mwbot::Bot::from_default_config().await.unwrap();
let page = bot.page("Project:Sandbox")?;
let wikitext = "This is a test edit!";
page.save(wikitext, &SaveOptions::summary("test edit!")).await?;
Page.save()
accepts both HTML and wikitext and supports the {{nobots}}
exclusion mechanism, among other features.
Try using one of the offered page generators to fetch and operate on multiple pages.
mwbot
is the flagship crate of the mwbot-rs
project.
We're always looking for new contributors, please reach out
if you're interested!
This crate is released under GPL-3.0-or-later. See COPYING for details.