Added oblique.py, a new web services module.

This commit is contained in:
Sean B. Palmer
2008-09-11 17:18:44 +01:00
parent 31d107c0bd
commit b91de3886e
7 changed files with 81 additions and 4 deletions

6
web.py
View File

@@ -16,18 +16,24 @@ class Grab(urllib.URLopener):
urllib._urlopener = Grab()
def get(uri):
if not uri.startswith('http'):
return
u = urllib.urlopen(uri)
bytes = u.read()
u.close()
return bytes
def head(uri):
if not uri.startswith('http'):
return
u = urllib.urlopen(uri)
info = u.info()
u.close()
return info
def post(uri, query):
if not uri.startswith('http'):
return
data = urllib.urlencode(query)
u = urllib.urlopen(uri, data)
bytes = u.read()