Python requests library
1.1k views · started by rosewill ·
Riddle had programmed his own HTTP class. That's what I've been using in my Python programs.
Chad wrote:Riddle had programmed his own HTTP class. That's what I've been using in my Python programs.
His is overly done. Hate to hate on him, but its a nasty class. Heres mine:
import urllib
import urllib2
import cookielib
class HTTPWrapper:
def __init__(self, KeepCookies=True):
if(KeepCookies):
self.cj = cookielib.CookieJar()
self.HTTP = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
else:
self.HTTP = urllib2.build_opener()
def Req(self, URL, data={}):
return self.HTTP.open(URL,urllib.urlencode(data)).read()
def GetBetween(self, s, leader, trailer):
end_of_leader = s.index(leader) + len(leader)
start_of_trailer = s.index(trailer, end_of_leader)
return s[end_of_leader:start_of_trailer]Beautifully simple!
Matt's is woefully simple :p
If you do use it, you may want to consider building on it a bit
If you do use it, you may want to consider building on it a bit

Artificial wrote:Matt's is woefully simple :p
If you do use it, you may want to consider building on it a bit
Its pretty easy to build upon also
Simple code is normally the preferred code.