mirror of
https://github.com/WikiTeam/wikiteam
synced 2024-11-12 07:12:41 +00:00
Merge pull request #125 from balr0g/check-for-disabled-api
Don't try to download sites with disabled API
This commit is contained in:
commit
6bbdf42ed0
@ -1032,12 +1032,15 @@ def checkAPI(api, config={}):
|
||||
req = urllib2.Request(url=api, data=urllib.urlencode({'action': 'query', 'meta': 'siteinfo', 'format': 'json'}), headers={'User-Agent': getUserAgent(), 'Accept-Encoding': 'gzip'})
|
||||
f = urllib2.urlopen(req)
|
||||
if f.headers.get('Content-Encoding') and 'gzip' in f.headers.get('Content-Encoding'):
|
||||
result = json.loads(gzip.GzipFile(fileobj=StringIO.StringIO(f.read())).read())
|
||||
resultText = gzip.GzipFile(fileobj=StringIO.StringIO(f.read())).read()
|
||||
else:
|
||||
result = json.loads(f.read())
|
||||
resultText = f.read()
|
||||
f.close()
|
||||
delay(config=config)
|
||||
print 'Checking api.php...', api
|
||||
if "MediaWiki API is not enabled for this site." in resultText:
|
||||
return False
|
||||
result = json.loads(resultText)
|
||||
delay(config=config)
|
||||
if result.has_key('query'):
|
||||
return True
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user