mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Updated to use webutils throughout.
This commit is contained in:
parent
0bbd05db58
commit
d134a2d9ac
@ -39,7 +39,6 @@ import supybot.plugins as plugins
|
||||
|
||||
import re
|
||||
import sets
|
||||
import urllib2
|
||||
|
||||
import supybot.registry as registry
|
||||
|
||||
@ -47,6 +46,7 @@ import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
import supybot.plugins as plugins
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.webutils as webutils
|
||||
import supybot.privmsgs as privmsgs
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
@ -89,9 +89,7 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
||||
def getStats(self, name):
|
||||
gkprofile = 'http://www.gameknot.com/stats.pl?%s' % name
|
||||
try:
|
||||
fd = urllib2.urlopen(gkprofile)
|
||||
profile = fd.read()
|
||||
fd.close()
|
||||
profile = webutils.getUrl(gkprofile)
|
||||
rating = self._gkrating.search(profile).group(1)
|
||||
games = self._gkgames.search(profile).group(1)
|
||||
(w, l, d) = self._gkrecord.search(profile).groups()
|
||||
@ -150,8 +148,8 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
||||
else:
|
||||
raise callbacks.Error,'The format of the page was odd. %s' % \
|
||||
conf.supybot.replies.possibleBug()
|
||||
except urllib2.URLError:
|
||||
raise callbacks.Error, 'Couldn\'t connect to gameknot.com'
|
||||
except webutils.WebError, e:
|
||||
raise callbacks.Error, webutils.strError(e)
|
||||
|
||||
|
||||
def gkstats(self, irc, msg, args):
|
||||
@ -174,9 +172,7 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
||||
if not self.registryValue('gameSnarfer', msg.args[0]):
|
||||
return
|
||||
url = match.group(0)
|
||||
fd = urllib2.urlopen(url)
|
||||
s = fd.read()
|
||||
fd.close()
|
||||
s = webutils.getUrl(url)
|
||||
try:
|
||||
if 'no longer available' in s:
|
||||
s = 'That game is no longer available.'
|
||||
|
@ -42,7 +42,6 @@ import sets
|
||||
import time
|
||||
import getopt
|
||||
import socket
|
||||
import urllib2
|
||||
import xml.sax
|
||||
|
||||
import SOAP
|
||||
@ -55,6 +54,7 @@ import supybot.utils as utils
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.plugins as plugins
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.webutils as webutils
|
||||
import supybot.privmsgs as privmsgs
|
||||
import supybot.callbacks as callbacks
|
||||
import supybot.structures as structures
|
||||
@ -381,10 +381,8 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
||||
m = match.group(0)
|
||||
header = {'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; '
|
||||
'Windows NT 4.0)'}
|
||||
request = urllib2.Request(m, headers=header)
|
||||
fd = urllib2.urlopen(request)
|
||||
text = fd.read()
|
||||
fd.close()
|
||||
request = webutils.Request(m, headers=header)
|
||||
text = webutils.getUrl(request)
|
||||
mThread = None
|
||||
mGroup = None
|
||||
if 'threadm=' in m:
|
||||
@ -392,19 +390,15 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
||||
if path is None:
|
||||
return
|
||||
url = 'http://groups.google.com%s' % path.group(1)
|
||||
request = urllib2.Request(url, headers=header)
|
||||
fd = urllib2.urlopen(request)
|
||||
text = fd.read()
|
||||
fd.close()
|
||||
request = webutils.Request(url, headers=header)
|
||||
text = webutils.getUrl(request)
|
||||
elif 'selm=' in m:
|
||||
path = self._ggSelm.search(m)
|
||||
if m is None:
|
||||
return
|
||||
url = 'http://groups.google.com/groups?%s' % path.group(0)
|
||||
request = urllib2.Request(url, headers=header)
|
||||
fd = urllib2.urlopen(request)
|
||||
text = fd.read()
|
||||
fd.close()
|
||||
request = webutils.Request(url, headers=header)
|
||||
text = webutils.getUrl(request)
|
||||
else:
|
||||
pass
|
||||
mThread = self._ggThread.search(text)
|
||||
|
@ -42,7 +42,6 @@ import sets
|
||||
import getopt
|
||||
import socket
|
||||
import urllib
|
||||
import urllib2
|
||||
import xml.dom.minidom
|
||||
from itertools import imap, ifilter
|
||||
|
||||
@ -235,7 +234,7 @@ class Http(callbacks.Privmsg):
|
||||
acronym = privmsgs.getArgs(args)
|
||||
url = 'http://www.acronymfinder.com/' \
|
||||
'af-query.asp?String=exact&Acronym=%s' % urllib.quote(acronym)
|
||||
request = urllib2.Request(url, headers={'User-agent':
|
||||
request = webutils.Request(url, headers={'User-agent':
|
||||
'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'})
|
||||
html = webutils.getUrl(request)
|
||||
if 'daily limit' in html:
|
||||
|
@ -38,10 +38,9 @@ __revision__ = "$Id$"
|
||||
|
||||
import supybot.plugins as plugins
|
||||
|
||||
import urllib2
|
||||
|
||||
import supybot.utils as utils
|
||||
import supybot.privmsgs as privmsgs
|
||||
import supybot.webutils as webutils
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
|
||||
@ -237,8 +236,7 @@ class OSU(callbacks.Privmsg):
|
||||
s = '.'.join(args)
|
||||
url = 'http://www.ohio-state.edu/cgi-bin/inquiry2.cgi?keyword=%s' % s
|
||||
try:
|
||||
fd = urllib2.urlopen(url)
|
||||
data = fd.read()
|
||||
data = webutils.getUrl(url)
|
||||
emails = []
|
||||
for line in data.splitlines():
|
||||
line.strip()
|
||||
|
@ -43,7 +43,6 @@ import sets
|
||||
import time
|
||||
import random
|
||||
import os.path
|
||||
import urllib2
|
||||
import UserDict
|
||||
import threading
|
||||
|
||||
|
@ -34,11 +34,13 @@ __revision__ = "$Id$"
|
||||
import supybot.fix as fix
|
||||
|
||||
import re
|
||||
import supybot.conf as conf
|
||||
import socket
|
||||
import urllib2
|
||||
import urlparse
|
||||
|
||||
import supybot.conf as conf
|
||||
|
||||
Request = urllib2.Request
|
||||
class WebError(Exception):
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user