getArticle not working with special characters in title
The program below works for en.wikipedia.org but for openwetware.org it outputs "Got: undefined" and this is the actual response returned from the server:
{"warnings":{"main":{"*":"Unrecognized parameter: rand."}},"batchcomplete":"","query":{"pages":{"-1":{"title":"Main%20Page","invalidreason":"The requested page title contains invalid characters: \"%20\".","invalid":""}}}}
#!/usr/bin/env node
var mw = require('nodemw');
var client = new mw({
protocol: "https",
server: "openwetware.org",
path: "/w",
debug: true
});
client.getArticle("Main Page", function(err, data) {
if(err) {
console.error(err);
process.exit(1);
}
console.log("Got:", data);
});
I believe you have to replace spaces in the title with underscores.
It works with spaces. I believe this pull request solves my problems.
But it does not work for me (with your fix applied) :)
info: nodemw v0.12.0 (node.js v6.12.0; linux x64)
Ah yes there was another problem. The openwetware.org mediawiki installation has a different script path so the path option had to be set to "/mediawiki".
The script path on a given wiki installation is available via the Special:Version page. It would be really cool if nodemw could auto-detect the script path given e.g. a URL to an arbitrary page on the wiki.