I recently learned how to scrape my mom's recipes from a cooking website. My current goal is to put those recipes into a self-hosted mediawiki server. Since all I know is python, I'm trying to use GET and POST requests and the API to create these pages. I've tried the various python scripts, like pywikibot, mwclient, and wptools to various forms of success. Documentation is really lacking for the latter two when it comes to editing/creating wiki pages, and pywikibot has some bugs (reported) that prevent me from logging on or using the pagefromfile.py script.
Luckily, there is a sample python code on mediawiki website.
username = 'myusername'
password = 'mypassword' # see https://www.mediawiki.org/wiki/Manual:Bot_passwords
api_url = 'https://my.wiki.com/api.php'
section = 'new'
sectiontitle = 'Ingredients'
summary = 'ingredients'
message = {" \n\u2022 6 db óriási nyers padlizsán <br>"
+"\n\u2022 4 db édes, húsos piros paprika, egészben <br>"
+"\n\u2022 3 db fekete paradicsom, vastagabb karikára szelve <br>"
+"\n\u2022 1 db zöld jalapeno paprika, egészben <br>"
+"\n\u2022 2 db nagy vöröshagyma, vastagabb karikára vágva <br>"
+"\n\u2022 10 cikk fokhagyma <br>"
+"\n\u2022 1 ek édes piros paprika <br>"
+"\n\u2022 ízlés szerint só <br>"
+"\n\u2022 ízlés szerint bors <br>"
}
page = 'Test'
This code creates a page with the relevant section and message, it looks like this.
Questions:
- How can I create more than one sectiontitle?
- If I put in wiki code, how come the mediawiki doesn't format it? For example, if I make the message "# 6db oriasi nyers" then mediawiki will create a message with "# 6db oriasi nyers" instead of "1. 6db oriasi nyers".