Use Python to help sister modify wechat movement steps, and sister calls experts directly (with complete source code)

Personal official account yk Kun Emperor
Get the complete source code and relevant configuration by replying to the movement steps in the background

hello everyone,

Only you can't imagine that no Python can't do it. Python helped WeChat girl to modify the Alipay sports the other day.

Today's article lets you screen WeChat's Alipay campaign.

Look at the effect first


Source code:

1. Project purpose

If you want to gather a lot of energy trees in Alipay ant forest, to make a force for the environment, or to dominate WeChat sports charts every day, but do not want to go out to walk, then the Python script can help you achieve. Only you can't think of it. You can't do it without Python. If you think my article is good, you are welcome to praise and collect it.

2. Implementation method

Mobile phone installs the third party software, the heart of the health (a sports software, safe and non-toxic, not selling software, project implementation needs, try several software, only this can be, you can try other software), registered account login, the motion data synchronization to WeChat and Alipay (need to authorize the relevant permissions). Then use the python script to remotely modify the steps of the current login account of Lexin health. Easy and simple, let's play WeChat sports and sweep Alipay's list.

**Step 1: * * install Lexin health app on your mobile phone.

Share two installation addresses directly (or install directly through the software store)

Android download address:( http://app.mi.com/details?id=gz.lifesense.weidong )

Apple download address:( https://apps.apple.com/us/app/lifesense-health/id1479525632 )

Step 2: register an account to log in, and then set the login password.

First enter my

Then click settings

Click account and security

Set password

The third step is to complete the third party synchronization and synchronize the motion data to WeChat and Alipay.

Enter data sharing in my

Then perform permission authorization

Step 4: run the python script and modify the number of happy heart health steps.


The effect of code running on wechat:

3. Python implementation parsing

The program setting is to automatically modify the steps at 7 o'clock every day (you can also modify it yourself and set the time. If you want to modify it automatically every day, upload the program to the server and add a cycle, you can automatically modify it every day). Replace and fill in the Lexin health account, Lexin health password and modification steps at the corresponding position of the following script (if you are worried about the account and password, you can also encrypt it, or store the account and password in the database and extract it directly), and then run the program. The recommended setting range of modification steps is 30000 to 90000 (try not to be too many, ha ha, enough is enough, enough is enough will not be detected) , too many steps will lead to unsuccessful modification. If you want to change the time of automatically modifying the steps the next day, please modify 25200 in the figure position, + 25200 represents the seconds added after 0:00 the next day, that is, 7x60x60, that is, 7 hours. You can modify it according to your own needs. If you want to modify the steps every day, just keep the program running all the time.

Note: running the program will immediately modify the steps of the day. The automatic modification of the steps starts from the second day when the program remains running. If you want to modify it now, run the code quickly.

Part of the source code, all source code acquisition methods are shown at the end of the article

Part I code

#Motion steps modification

import requests
import json
import hashlib
import time
import datetime


class LexinSport:
    def __init__(self, username, password, step):
        self.username = username
        self.password = password
        self.step = step

    # Sign in
    def login(self):
        url = 'https://sports.lifesense.com/sessions_service/login?systemType=2&version=4.6.7'
        data = {'loginName': self.username, 'password': hashlib.md5(self.password.encode('utf8')).hexdigest(),
                'clientId': '49a41c9727ee49dda3b190dc907850cc', 'roleType': 0, 'appType': 6}
        headers = {
            'Content-Type': 'application/json; charset=utf-8',
            'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 7.1.2; LIO-AN00 Build/LIO-AN00)'
        }
        response_result = requests.post(url, data=json.dumps(data), headers=headers)
        status_code = response_result.status_code
        response_text = response_result.text
        # print('login status code:% s'% status_code)
        # print('login return data:% s'% response_text)
        if status_code == 200:
            response_text = json.loads(response_text)
            user_id = response_text['data']['userId']
            access_token = response_text['data']['accessToken']
            return user_id, access_token
        else:
            return 'Login failed'

Part II code

    # Modify steps
    def change_step(self):
        # Login results
        login_result = self.login()
        if login_result == 'Login failed':
            return 'Login failed'
        else:
            url = 'https://sports.lifesense.com/sport_service/sport/sport/uploadMobileStepV2?systemType=2&version=4.6.7'
            data = {'list': [{'DataSource': 2, 'active': 1, 'calories': int(self.step/4), 'dataSource': 2,
                              'deviceId': 'M_NULL', 'distance': int(self.step/3), 'exerciseTime': 0, 'isUpload': 0,
                              'measurementTime': time.strftime('%Y-%m-%d %H:%M:%S'), 'priority': 0, 'step': self.step,
                              'type': 2, 'updated': int(round(time.time() * 1000)), 'userId': login_result[0]}]}
            headers = {
                'Content-Type': 'application/json; charset=utf-8',
                'Cookie': 'accessToken=%s' % login_result[1]
            }
            response_result = requests.post(url, data=json.dumps(data), headers=headers)
            status_code = response_result.status_code
            # response_text = response_result.text
            # print('modify steps status code:% s'% status_code)
            # print('return data of modified steps:% s'% response_text)
            if status_code == 200:
                return 'The number of modification steps is[%s]success' % self.step
            else:
                return 'Failed to modify steps'


# Time from sleep to execution of modification steps the next day
def get_sleep_time():
    # Day 2 date
    tomorrow = datetime.date.today() + datetime.timedelta(days=1)
    # 7:00 time stamp the next day
    tomorrow_run_time = int(time.mktime(time.strptime(str(tomorrow), '%Y-%m-%d'))) + 25200
    # print(tomorrow_run_time)
    # Current timestamp
    current_time = int(time.time())
    # print(current_time)
    return tomorrow_run_time - current_time


if __name__ == "__main__":
    # Maximum number of run errors
    fail_num = 3
    while 1:
        while fail_num > 0:
            try:
                # Modify step results
                result = LexinSport('Happy heart health account', 'Happy heart health password', 'Modify steps').change_step()
                print(result)
                break
            except Exception as e:
                print('Run error, reason:%s' % e)
                fail_num -= 1
                if fail_num == 0:
                    print('Failed to modify steps')
        # Reset run errors
        fail_num = 3
        # Get sleep time
        sleep_time = get_sleep_time()
        time.sleep(sleep_time)

Finally, related configurations are required

PS: if you think my article is good, you are welcome to press one button three times. Your support is the biggest driving force for my creation.

Personal official account yk Kun Emperor
Get the complete source code and relevant configuration by replying to the movement steps in the background

Keywords: Python wechat Project

Added by Rai_de on Tue, 09 Nov 2021 21:42:03 +0200