def http_header(self, client):
        self.host = client.host
        self.header = client.header
        self.path = client.path
        self.data = ""
        header = {}
        header = dict([(l[0], l[1]) for l in client.header.items()])
        #print "RECURSE GET",self.host + self.path ,client.status[0] , client.status[1]
        if (client.status[1] == "301" or client.status[1] == "302"):
	    http_client_proxy.do_request(header['location'], mamba_parser_recurse())
    def http_header(self, client):
        self.host = client.host
        self.header = client.header
        self.path = client.path
        self.data = ""
        header = {}
        header = dict([(l[0], l[1]) for l in client.header.items()])
        if (client.status[1] == "301"):
	    http_client_proxy.do_request(header['location'], parser())
	else:
    	    print self.host + self.path +" "+ client.status[0] + " " + client.status[1]
def getit():
    while len(mambapoolsize)<50 and len(mambaquery) >0:

	url=mambaquery.pop()

	if url.find("/photo/") > 0:
	    http_client_proxy.do_request(url, mamba_photo_parser())
	else:
	    http_client_proxy.do_request(url, mamba_user_parser())

	mambapoolsize.append(url)
	time.sleep(1)
    def http_header(self, client):
        self.host = client.host
        self.header = client.header
        self.path = client.path
        self.data = ""
        header = {}
        header = dict([(l[0], l[1]) for l in client.header.items()])
        if (client.status[1] == "301" or client.status[1] == "302"):
	    http_client_proxy.do_request(header['location'], mamba_user_recurse())
	    return
	if (client.status[1] != "200"):
	    http_client_proxy.do_request(header['location'], mamba_user_recurse())
	    return
def getit():
    while len(bebopoolsize)<1 and len(bebopool)>0:
        url=bebopool.pop()
        http_client_proxy.do_request(url, parser())
        bebopoolsize.append(url)


def write():
    writer.writerows(mambapool)
    del mambapool[0:len(mambapool)]



def getit():
    while len(mambapoolsize)<50 and len(mambaquery) >0:

	url=mambaquery.pop()

	if url.find("/photo/") > 0:
	    http_client_proxy.do_request(url, mamba_photo_parser())
	else:
	    http_client_proxy.do_request(url, mamba_user_parser())

	mambapoolsize.append(url)
	time.sleep(1)

offset=0
while True:
    try:
	http_client_proxy.do_request("http://mamba.ru/search.phtml?offset="+str(offset)+"&s_l=F&s_i=M&s_f=18&s_t=25&s_c=3159_4312_4400&s_m=0&s_p=checked&s_w=checked&s_ty=All&s_vf=&s_vw=&s_vip=&s_v=&search_mode=Base&gid=260234362", mamba_parser_recurse())
        asyncore.loop()
	offset=offset+10
    except:
	offset=offset-10