Microsoft-Rewards-Bot icon indicating copy to clipboard operation
Microsoft-Rewards-Bot copied to clipboard

ERROR :: root :: Cannot find key "userStatus"

Open Chris9a opened this issue 1 year ago • 2 comments

I have had a userStatus error for a week now. Any way to fix it?

Chris9a avatar Mar 25 '23 00:03 Chris9a

I have had a userStatus error for a week now. Any way to fix it?

Yep I've been testing a change to the xpath for it. It's in the stats.py file, function _get_user_status_json.

I'll post it when I'm at my PC later today.

Update - try this tweak, I've commented out the old version of the line.

    def _get_user_status_json(self):
        js = self._browser.find_elements(By.XPATH, 
            '//script[text()[contains(., "userStatus")]]')
        if not js:
            return {}

        matches = re.search(
            #r'(?=\{"userStatus":).*(=?\}\};)', js[0].get_attribute('text'))
            r'(?=\{"userStatus":).*(=?\};)', js[0].get_attribute('text'))
        if not matches:
            return {}
        return json.loads(matches[0][:-1])

ashanrath avatar Mar 25 '23 00:03 ashanrath

Awesome. Your fix worked, thank you.

Chris9a avatar Mar 25 '23 04:03 Chris9a