Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.
UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.
Python:Counter.py
Copyright (c) 2008 Monobi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import wikipedia import os, sys import re def main(): site = wikipedia.getSite() page = wikipedia.Page(site, 'PAGETOCOUNTTHELINKSON') # this is the page to count the number of links on print page try: text = page.get() count = len(re.findall('\[\[(.*?)\]\]',text,re.I)) # this regex counts links countimages = len(re.compile('\[\[Image', re.IGNORECASE).findall(text, re.I)) #this regex counts image links newestnumber = count - countimages # this line removes images from the total, remove it if you want to count images as links print newestnumber update = str(newestnumber) pagetwo = wikipedia.Page(site, 'PAGETOPOSTTHELINKSON') # this is the page to post the number of links texttwo = pagetwo.get() final = '<span style="color: grey; font-family: Calibri;">' + update + '</span>' #this is what you'll post on the wiki if final == texttwo: wikipedia.output(u"The count equals the text, not updating") pass elif final != text: wikipedia.output(u"The count did not equal the text, updating") pagetwo.put(final, 'EDITSUMMARYGOESHERE', minorEdit = True) # place your edit summary except wikipedia.Error(): wikipedia.output(u"Error, skipping") if __name__ == '__main__': try: main() finally: wikipedia.stopme()