[removed]
Results 1 to 5 of 5
Thread: Python requests library
- 08 Mar. 2012 05:59am #1
[removed]
Last edited by rosewill; 13 Sep. 2024 at 03:04pm.
- 09 Mar. 2012 01:08am #2
- 09 Mar. 2012 01:59am #3
His is overly done. Hate to hate on him, but its a nasty class. Heres mine:
Code: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]
- 11 Mar. 2012 12:05am #4
Matt's is woefully simple :p
If you do use it, you may want to consider building on it a bit
- 11 Mar. 2012 08:07pm #5