summaryrefslogtreecommitdiffstats
path: root/web.py
diff options
context:
space:
mode:
authorSean B. Palmer <http://inamidst.com/sbp/>2008-02-21 12:06:33 +0000
committerSean B. Palmer <http://inamidst.com/sbp/>2008-02-21 12:06:33 +0000
commit7931fab14599b739c18c8f1ebcc24b75688dbc09 (patch)
treebf4df9757f10c155e3b6f78aed48f15884ebbbe6 /web.py
downloadbot-7931fab14599b739c18c8f1ebcc24b75688dbc09.tar.gz
bot-7931fab14599b739c18c8f1ebcc24b75688dbc09.tar.bz2
bot-7931fab14599b739c18c8f1ebcc24b75688dbc09.zip
Phenny2, now being tested on Freenode as the main phenny.
Diffstat (limited to 'web.py')
-rwxr-xr-xweb.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/web.py b/web.py
new file mode 100755
index 0000000..fff4a7f
--- /dev/null
+++ b/web.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+"""
+web.py - Web Facilities
+Author: Sean B. Palmer, inamidst.com
+About: http://inamidst.com/phenny/
+"""
+
+import urllib
+
+class Grab(urllib.URLopener):
+ def __init__(self, *args):
+ self.version = 'Mozilla/5.0 (Phenny)'
+ urllib.URLopener.__init__(self, *args)
+ def http_error_default(self, url, fp, errcode, errmsg, headers):
+ return urllib.addinfourl(fp, [headers, errcode], "http:" + url)
+urllib._urlopener = Grab()
+
+def get(uri):
+ u = urllib.urlopen(uri)
+ bytes = u.read()
+ u.close()
+ return bytes
+
+def head(uri):
+ u = urllib.urlopen(uri)
+ info = u.info()
+ u.close()
+ return info
+
+def post(uri, query):
+ data = urllib.urlencode(query)
+ u = urllib.urlopen(uri, data)
+ bytes = u.read()
+ u.close()
+ return bytes
+
+if __name__=="__main__":
+ main()