移动小one易统计定时打卡(python) – 记忆角落

移动小one易统计定时打卡(python)

/ 0评 / 54
1.电脑端登录易统计官网获取token

通过几个账号不间断测试,判断出每个用户都有固定的且不变的一个token值。但需要每周手机登录一次,至于为什么我还真的不知道~

登录官网:https://www.ioteams.com/ncov/#/login,如下图

输入对应账号(手机号码)

image-20210227193607099

登录后,F12打开浏览器开发调试工具,点击Network(网络),之后刷新一下页面,找到ncov,点击,选择cookie,再找到对应ncov-access-token-h5的值,如下红框:

image-20210227194044032

2.修改python代码对应的值

修改的值如下:

  1. ncov-access-token值为步骤一获取的
  2. address的地址数据,可通过点击 立即上报/重新上报按钮 获取上一次签到信息:

image-20210227195207888

image-20210227195132798

返回数据只需要获取address下的数据补充即可,如下:

image-20210227195503629

最后代码如下:
# coding=utf-8
import time
import random
import requests
import json


#接口header
headers = {
    "Content-Type": "application/json;charset=utf-8",
    "Connection": "keep-alive",
    "Host": "www.ioteams.com",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 Edg/88.0.705.74",
    "ncov-access-token": "",#用户token是唯一且不变的,获取方法见上文。

}
#打卡信息
data = {
    "address": {
        "province": "440000",#省份代码
        "city": "440100",#市区代码
        "county": "440113",#县级代码
        "autoFetch": True,
        "lng": "113.3896",#填写当前地区经度
        "lat": "22.9709"#填写当前地区纬度
    },
    "at_home": True,
    "contacted": False,
    "custom": {
        "dzmgi": "在家远程办公",
        "egdtb": "否",
        "fykat": "否",
        "otqdu": "否"
    },

    # "family_suspected": False,
    # "family_confirmed": False,
    "fever": False,#是否发热
    "infected": False,#是否感染
    "self_suspected": False,
    "self_confirmed": False,
    "description": ""
    # "contacted_beijing":False,
    # "passed_beijing":False,
}


def get_login():
    random_sleep()
    link = 'https://www.ioteams.com/ncov/#/index'
    try:
        req = requests.get(link, headers=headers)
        print(req.content)
    except Exception as e:
        print(e)



# 获取当前日报id
def get_dailyCode():
    link = 'https://www.ioteams.com/ncov/api/users/dailyReport'
    # link = 'https://www.ioteams.com/ncov/api/companies/default/question'
    # link = 'https://www.ioteams.com/ncov/api/statistical/latest'
    try:
        # req = requests.get(link, headers=headers)
        req = requests.post(link, headers=headers, data=json.dumps(data))
        response = req.json()
        print(req.json())
        user_id = response['data']['data']['_id']
        print(user_id)
        return user_id
    except Exception as e:
        print(e)


# 打卡
def report_health():
    get_login()
    user_id = get_dailyCode()
    time.sleep(5)
    url = 'https://www.ioteams.com/ncov/api/users/dailyReports/{}'
    req = requests.put(url.format(user_id), headers=headers, data=json.dumps(data))
    print(req)
    print(req.json())


def random_sleep():
    sleep_time = random.randint(200, 1000)
    print(sleep_time)
    time.sleep(sleep_time)


if __name__ == '__main__':
    report_health()
    # get_dailyCode()

 

3.每日定时执行

通过自己Linux服务器每日定时执行即可:

我是直接crontab 每天0点10分定时执行的.....

10 0 * * * python /data/glj/oneSign.py > log.log

发表评论

您的电子邮箱地址不会被公开。