How to translate script i python 2,7
Question: This script works in Python34 How translate in Python27?

    
    
    import urllib.request, re, urllib.parse
    from base64 import b64encode
    import codecs
    import time
    
    def send_cap(key, fn):
        print ('1')
        data=open(fn, 'rb')
        print ('2')
        s = b64encode(data.read())
        print ('3')
        image = s.decode('latin-1')
        print ('4')
        params = urllib.parse.urlencode({'method': 'base64', 'key': key, 'body':image, 'ext':'jpg'})
        print ('5')
        bindata=params.encode('ascii')
        f = urllib.request.urlopen("http://antigate.com/in.php", bindata)#params)
        print ('6')
        res = str(f.read().decode())
        print(res)
        cap_id = re.search('\d+',res)
        if cap_id == None:
            return False
        else:
            idc = cap_id.group(0)
            return idc
    
    def get_cap_text(key, cap_id):
    
    
        time.sleep(5)
    
        res_url= 'http://antigate.com/res.php'
        res_url+= "?" + urllib.parse.urlencode({'key': key, 'action': 'get', 'id': cap_id})
        flag=False
        while flag==False:
            res= urllib.request.urlopen(res_url).read()
            res = res.decode()
            if res == 'CAPCHA_NOT_READY':
                time.sleep(1)
            else:
                flag=True
        res= re.split('[\W]+',res)
        if len(res[0]) == 2:
            return res[1]
        else:
            return ('ERROR', res[0])
    
    res = send_cap('eeeee','capcha2.jpg')
    print(res)
    text= get_cap_text('eeeee', res)
    print (text)
    


Answer: If this works in Python 3, then you should change a few lines containing
`urllib` to convert:

    
    
    import urllib, re # first line of imports
    
    urllib.urlopen # no urllib.request
    urllib.urlencode # no urllib.parse
    

