示例#1
0
def register_account(id1,id2,id3):
    try:
        print 'Register %s%s%s starts' % (id1,id2,id3)
        driver.get("https://aaa.pinnaclesports.com/Members/NewMember.aspx")
        while driver.title != "Pinnacle Sports":
            time.sleep(0.5)
        for i in range(10):
            Select(driver.find_element_by_id('ctl00_PCPH_AL3DDL')).select_by_index(i)
            time.sleep(1)
            driver.find_element_by_id('ctl00_PCPH_PTB').send_keys(Keys.NULL)
            time.sleep(1)
            if id1 in [opt.text for opt in Select(driver.find_element_by_id('ctl00_PCPH_AL1DDL')).options]:
                break
        driver.find_element_by_id('ctl00_PCPH_AL1DDL').send_keys(id1)
        for i in range(10):
            Select(driver.find_element_by_id('ctl00_PCPH_AL3DDL')).select_by_index(i)
            time.sleep(1)
            driver.find_element_by_id('ctl00_PCPH_PTB').send_keys(Keys.NULL)
            time.sleep(1)
            if id2 in [opt.text for opt in Select(driver.find_element_by_id('ctl00_PCPH_AL2DDL')).options]:
                break
        driver.find_element_by_id('ctl00_PCPH_AL2DDL').send_keys(id2)
        for i in range(3):
            driver.find_element_by_id('ctl00_PCPH_AL3DDL').click()
            time.sleep(1)
            driver.find_element_by_id('ctl00_PCPH_PTB').send_keys(Keys.NULL)
            time.sleep(1)
            if id3 in [opt.text for opt in Select(driver.find_element_by_id('ctl00_PCPH_AL3DDL')).options]:
                break
        driver.find_element_by_id('ctl00_PCPH_AL3DDL').send_keys(id3)
        driver.find_element_by_id('ctl00_PCPH_PTB').send_keys(default_password)
        driver.find_element_by_id('ctl00_PCPH_MCTB').send_keys(credit)
        driver.find_element_by_id('ctl00_PCPH_OTDDL').send_keys('Hong Kong Odds')
        driver.find_element_by_id('ctl00_PCPH_CDDL').send_keys('China')
        driver.find_element_by_id('ctl00_PCPH_CustomerWagerMaxSelectionCtrl_DDWagerMaximumSelection').send_keys('Regular Maximums')
        driver.find_element_by_id('ctl00_PCPH_CaptchaControl_InputTB').send_keys(Keys.NULL)
        sid1 = Select(driver.find_element_by_id('ctl00_PCPH_AL1DDL')).first_selected_option.get_attribute("value")
        sid2 = Select(driver.find_element_by_id('ctl00_PCPH_AL2DDL')).first_selected_option.get_attribute("value")
        sid3 = Select(driver.find_element_by_id('ctl00_PCPH_AL3DDL')).first_selected_option.get_attribute("value")
        print "Selected %s%s%s" % (sid1,sid2,sid3)
        e_capcha = driver.find_element_by_id('ctl00_PCPH_CaptchaControl_CaptchaImg')
        rect = e_capcha.rect
        driver.save_screenshot(cap_path)
        # Crop the capcha
        im = Image.open(cap_path) # uses PIL library to open image in memory
        left = rect['x']
        top = rect['y']
        right = rect['x'] + rect['width']
        bottom = rect['y'] + rect['height']
        im = im.crop((left, top, right, bottom)) # defines crop points
        im.save(cap_path) # saves new cropped image
        # Enter the capcha
        cap = ""
        cap = uuClient.get_capcha(cap_path)
        if cap == "":
            print "Cannont get capcha"
            return False
        driver.find_element_by_id('ctl00_PCPH_CaptchaControl_InputTB').send_keys(cap)
        if "%s%s%s" % (sid1,sid2,sid3) != '%s%s%s' % (id1,id2,id3):
            winsound.Beep(Freq,Dur)
            raw_input("Press any key to continue.")
        driver.find_element_by_id("ctl00_PCPH_CRB").click()
        time.sleep(5)
        while 1:
            if "TaskMonitor" in driver.current_url:
                print "Success"
                print 'Register %s%s%s ends' % (id1,id2,id3)
                return True
            elif "NewMember" in driver.current_url:
                print "Fail"
                print 'Register %s%s%s ends' % (id1,id2,id3)
                return False
    except Exception as e:
        print e
        return False
示例#2
0
 time.sleep(2)
 driver.find_element_by_id("loginUsername").send_keys(agent_username)
 driver.find_element_by_id("loginPassword").send_keys(agent_password)
 e_capcha = driver.find_element_by_id('captchaImage')
 rect = e_capcha.rect
 driver.save_screenshot(cap_path)
 # Crop the capcha
 im = Image.open(cap_path) # uses PIL library to open image in memory
 left = rect['x']
 top = rect['y']
 right = rect['x'] + rect['width']
 bottom = rect['y'] + rect['height']
 im = im.crop((left, top, right, bottom)) # defines crop points
 im.save(cap_path) # saves new cropped image
 #Enter the capcha
 cap = ""
 cap = uuClient.get_capcha(cap_path)
 if cap == "":
     print "Cannont get capcha"
 driver.find_element_by_id("captcha").send_keys(cap)    
 driver.find_element_by_name("loginSubmit").click()
 while "balance" not in driver.current_url:
     time.sleep(0.5)
 url_new = ""
 for e in driver.find_elements_by_xpath("//a"):
     if "agentCreation" in e.get_attribute('href'):
         url_new = e.get_attribute('href')
         break
 if url_new != "":
     register_accounts(id_from, id_to)      
 raw_input("Press any key to quit.")
示例#3
0
def register_account(id1,id2,id3):
    try:
        print 'Register %s%s%s starts' % (id1,id2,id3)
        driver.switch_to_default_content()
        driver.switch_to_frame(driver.find_element_by_id('menu'))
        time.sleep(3)
        for e in driver.find_elements_by_tag_name('a'):
            if "New Member" in e.text:
                newmember = e
                break
        newmember.click()
        time.sleep(3)
        driver.switch_to_default_content()
        driver.switch_to_frame(driver.find_element_by_id('main'))
        driver.switch_to_frame(driver.find_element_by_id('frmAddNewMember'))
        time.sleep(0.5)
        driver.find_element_by_id("txtUserName").clear()
        time.sleep(0.5)
        driver.find_element_by_id("txtUserName").send_keys('PYRC701000')
        time.sleep(0.5)
        driver.find_element_by_id("sbuttonReView").click()
        time.sleep(3)
        driver.find_element_by_id("sbuttonNext").click()
        time.sleep(3)
        driver.find_element_by_id("txtCredit").send_keys(credit)
        time.sleep(0.5)
        driver.find_element_by_id("txtPwd").send_keys(default_password)
        time.sleep(0.5)
        driver.find_element_by_id("Number1").send_keys(id1)
        time.sleep(0.5)
        driver.find_element_by_id("Number2").send_keys(id2)
        time.sleep(0.5)
        driver.find_element_by_id("Number3").send_keys(id3)
        time.sleep(0.5)
        driver.find_element_by_id("sbuttonNext").click()
        time.sleep(10)
        while 1:
			e_capcha = None
            try:
                driver.switch_to_default_content()
                main = driver.find_element_by_id('main')
                rect1 = main.rect
                driver.switch_to_frame(main)
                addnew = driver.find_element_by_id('frmAddNewMember')
                rect2 = addnew.rect
                driver.switch_to_frame(addnew)
                frCaptcha = driver.find_element_by_id('frCaptcha')
                rect3 = frCaptcha.rect
                driver.switch_to_frame(driver.find_element_by_id('frCaptcha'))
                e_capcha = driver.find_element_by_id('CaptchaImage')
            except:
                break
            if e_capcha is None:
                break
            rect = e_capcha.rect
            driver.save_screenshot(cap_path)
            # Crop the capcha
            im = Image.open(cap_path) # uses PIL library to open image in memory
            x = rect['x'] + rect1['x'] + rect2['x'] + rect3['x']
            y = rect['y'] + rect1['y'] + rect2['y'] + rect3['y']
            left = x
            top = y
            right = x + rect['width']
            bottom = y + rect['height']
            im = im.crop((left, top, right, bottom)) # defines crop points
            im.save(cap_path) # saves new cropped image
            # Enter the capcha
            cap = ""
            for i in range(3):
                cap = uuClient.get_capcha(cap_path)
                if cap != "":
                    break
            else:
                return False
            driver.find_element_by_id("recaptcha_response_field").send_keys(cap)  
            driver.find_element_by_id("SubmitCaptcha").click()
            time.sleep(2)
            driver.switch_to_default_content()
            driver.switch_to_frame(driver.find_element_by_id('main'))
            driver.switch_to_frame(driver.find_element_by_id('frmAddNewMember'))
            driver.find_element_by_id("sbuttonNext").click()
            time.sleep(10)
        time.sleep(30)
        return True
示例#4
0
def activate_account(username):
    try:
        print 'Activate ', username
        #username = '******'
        #password = '******'
        driver = webdriver.Firefox()
        driver.implicitly_wait(30)
        #driver.set_window_size(100, 100)
        #driver.set_window_position(-200, -200)
        driver.get("http://www.isn99.com/membersite/login.jsp")
        time.sleep(2)  
        driver.find_element_by_id("username").send_keys(username)
        driver.find_element_by_id("password").send_keys(old_password)
        e_capcha = driver.find_element_by_class_name('captcha')
        rect = e_capcha.rect
        driver.save_screenshot(cap_path)
        # Crop the capcha
        im = Image.open(cap_path) # uses PIL library to open image in memory
        left = rect['x']
        top = rect['y']
        right = rect['x'] + rect['width']
        bottom = rect['y'] + rect['height']
        im = im.crop((left, top, right, bottom)) # defines crop points
        im.save('capcha.png') # saves new cropped image
        #Enter the capcha
        cap = ""
    #    webbrowser.open('capcha.png')
    #    while 1:
    #        cap = str(raw_input("Enter capcha: ")).strip()
    #        if len(cap) == 4:
    #            break
        cap = uuClient.get_capcha(cap_path)
        if cap == "" or len(cap) != 4:
            print "Cannont get capcha"
            return False
        driver.find_element_by_id("code").send_keys(cap)   
        driver.find_element_by_id("login").click()
        while "membersite" not in driver.current_url:
            time.sleep(1)  
        time.sleep(2)  
        driver.find_element_by_class_name("tnc-agree").click()   
        while 'membersite' not in driver.current_url:
            time.sleep(0.5) 
        time.sleep(2)  
        driver.find_element_by_name('oldPassword').send_keys(old_password)
        driver.find_element_by_name('newPassword').send_keys(new_password)
        driver.find_element_by_name('confirmPassword').send_keys(new_password)
        driver.find_element_by_class_name("changePassword").click()
        alert_handle(driver) 
        while 'membersite' not in driver.current_url:
            time.sleep(0.5) 
        time.sleep(2)  
        driver.find_element_by_class_name("updatePreference").click()
        alert_handle(driver)
        while 'membersite' not in driver.current_url:
            time.sleep(0.5)
        alert_handle(driver)
        nickname = username[0] + username[-9:]
        driver.find_element_by_id('loginName').send_keys(nickname)
        driver.find_element_by_class_name("confirmLogin").click()
        alert_handle(driver)
        time.sleep(1)
        driver.close()
        
        return True
    except (WindowsError,selenium.common.exceptions.WebDriverException) as e:
        print e
        return False