charlesbel / Microsoft-Rewards-Farmer

A simple bot that uses selenium to farm Microsoft Rewards written in Python
MIT License
975 stars 261 forks source link

[BUG] Mobile Search does not ensure log in/gets stuck (Solution Found) #155

Closed AlexyGalaxy closed 1 year ago

AlexyGalaxy commented 1 year ago

Desktop seaches run normally. Mobile searches, Writes email, Writes password, Passes security checks, Logs in. But gets stuck on Ensuring login on Bing.

I am looking into a solution now. By using headless mode and will post my results below.

AlexyGalaxy commented 1 year ago

Fixed this issue by changing checkBingLogin:

def checkBingLogin(browser: WebDriver, isMobile: bool = False):
    try :
        global POINTS_COUNTER
        #Access Bing.com
        browser.get('https://bing.com/')
        # Wait 8 seconds
        time.sleep(8)
        #Accept Cookies
        try:
            browser.find_element(By.ID, 'bnp_btn_accept').click()
        except:
            pass
        if isMobile:
            try:
                time.sleep(6)
                try:
                    browser.find_element(By.XPATH,'//*[@id="mHamburger"]').click()
                except:
                    browser.find_element(By.ID, 'mHamburger').click()
                    pass
            except:
                try:
                    browser.find_element(By.ID, 'bnp_btn_accept').click()
                except:
                    pass
                try:
                    browser.find_element(By.ID, 'bnp_ttc_close').click()
                except:
                    pass
                time.sleep(2)
                try:
                    browser.find_element(By.ID, 'mHamburger').click()
                except:
                    pass
            try:
                time.sleep(2)
                browser.find_element(By.ID, 'HBSignIn').click()
            except:
                pass
            try:
                time.sleep(2)
                browser.find_element(By.ID, 'iShowSkip').click()
                time.sleep(3)
            except:
                if str(browser.current_url).split('?')[0] == "https://account.live.com/proofs/Add":
                    input('[LOGIN] Please complete the Security Check on ' + browser.current_url)
                    exit()
        #Wait 3 seconds
        time.sleep(3)
    except:
        prRed('\n[ERROR] An Error has Occured While Trying to Check Bing Login.\n')
    if not isMobile:
        #Refresh page
        browser.get('https://bing.com/')
        #Wait 5 seconds
        time.sleep(10)
    try :
    #Update Counter
        try:
            if not isMobile:
                POINTS_COUNTER = int(browser.find_element(By.ID, 'id_rc').get_attribute('innerHTML'))
            else:
                try:
                    browser.find_element(By.ID, 'mHamburger').click()
                except:
                    try:
                        browser.find_element(By.ID, 'bnp_btn_accept').click()
                    except:
                        pass
                    try:
                        browser.find_element(By.ID, 'bnp_ttc_close').click()
                    except:
                        pass
                    time.sleep(2)
                    browser.find_element(By.ID, 'mHamburger').click()
                time.sleep(2)
                POINTS_COUNTER = int(browser.find_element(By.ID, 'fly_id_rc').get_attribute('innerHTML'))
        except:
            checkBingLogin(browser, isMobile)
    except:
        prRed('\n[ERROR] An Error has Occured While Trying to Check Bing Login Mobile.\n')

I have uploaded an updated version of this scrip to my github. It allows for more quizes to be completed as bing rewards keeps updating. I also added timers and counters and im working on adding a logger and error logger.

If you would like to check it out my github link is: https://github.com/AlexyGalaxy/Microsoft-Rewards-Farmer

crhywun commented 1 year ago

I use your version, but I still get stuck sometimes. most of time,it work well.

AlexyGalaxy commented 1 year ago

Im sorry I dont understand. You are using my code thats posted above or you are using the script on my github?

When you do get stuck do you know where you are getting stuck? Can you provide a screen shot of your cmd/console using the snipping tool?

If you want to troubleshoot the issue on your own to find out eactly what is happening; try disabling headless mode by commenting out line 46 and 47 with #. Then watch the script open chrome and look to see where it is stuck. (When done testing make sure to delete the # to rentable headless mode.

#if headless_mode : #comment out to disable headless mode (makes window visable) 
           #options.add_argument("--headless") #comment out to disable headless mode (makes window visable) 
GuyGieri commented 1 year ago

Im also still having an issue where it gets stuck on mobile search login. I disabled headless mode, here is where it gets stuck:

AlexyGalaxy commented 1 year ago

I added a retry feature to make sure that the ensure login function works properly and updated it to my github.

https://github.com/AlexyGalaxy/Microsoft-Rewards-Farmer

djzombek commented 1 year ago

I added a retry feature to make sure that the ensure login function works properly and updated it to my github.

https://github.com/AlexyGalaxy/Microsoft-Rewards-Farmer

Just letting you know, I tried your script and had to comment out line 252 or it gets caught in a recursive loop; something seems to be wrong with the counting feature after this change. Fellow developer just letting you know; It's late at night right now but I can look at it later if you'd like me to help figure it out.

AlexyGalaxy commented 1 year ago

Thanks for pointing this out to me. There is another issue where the while loop on line 145 is caught in an infinite loop. I only added an end condition for mobile searches. I now have end conditions for both mobile and desktop and removed the function you mentioned to stop the infinite loop. I updated the code.

https://github.com/AlexyGalaxy/Microsoft-Rewards-Farmer

GuyGieri commented 1 year ago

Works now, good stuff!

Maxwell-Bean commented 1 year ago

As I note, I was stuck here too but it was because my password was incorrect. Once I changed that and ran it a few times in headless mode, everything worked! Excellent work @AlexyGalaxy !

charlesbel commented 1 year ago

Fixed with v3.0 #188

cmulittlechild commented 8 months ago

Thanks for pointing this out to me. There is another issue where the while loop on line 145 is caught in an infinite loop. I only added an end condition for mobile searches. I now have end conditions for both mobile and desktop and removed the function you mentioned to stop the infinite loop.谢谢你向我指出这一点。还有另一个问题,即第 145 行的 while 循环陷入了无限循环。我只为移动搜索添加了一个结束条件。我现在有移动和桌面的结束条件,并删除了您提到的停止无限循环的功能。 I updated the code.我更新了代码。

https://github.com/AlexyGalaxy/Microsoft-Rewards-Farmer

hi, it seems you delete your codes? i can not find all of them, especially the zip file you mentioned on your repo porfile.