#!/usr/bin/env python2 # -*- coding: utf-8 -*- # Copyright (C) 2011-2012 WikiTeam # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Script to check if a list of wikis are alive or dead import thread import time import sys import urllib2 import exceptions import re # Configuration delay = 30 # Seconds before timing out on request limit = 100 def printapi(api): print api, 'is alive' open('wikisalive.txt', 'a').write(('%s\n' % api.strip()).encode('utf-8')) def checkcore(api): req = urllib2.Request(api, None) try: raw = urllib2.urlopen(req, None, delay).read() except IOError: # http://docs.python.org/2/howto/urllib2.html#handling-exceptions print api, 'is dead or has errors' return # RSD is available since 1.17, bug 25648 rsd = re.search(r'(?:link rel="EditURI".+href=")(?:https?:)?(.+api.php)\?action=rsd', raw) # Feeds are available, with varying format, in 1.8 or earlier feed = re.search(r'(?:link rel="alternate" type="application/)(?:atom|rss)(?:\+xml[^>]+href="/)([^>]*index.php)(?:\?title=[^>]+&)(?:feed|format)', raw) # Sometimes they're missing though, this should catch the rest but goes out of login = re.search(r'(?: