乐动力刷微信步数失败

import pandas as pd
import time
import requests
import json
def get_post1():
    # url = "http://pl.api.ledongli.cn/xq/io.ashx"
    url = "http://walk.ledongli.cn/rest/dailystats/upload/v3"
    # url = "http://walk.ledongli.cn/rest/dailystats/upload/v3?uid=77103858&pc=uuid68176b9878a7ac5c9bb655e2a4840214099f7b5a&v=8.4%20ios"

    headers = {
        # "Host": "walk.ledongli.cn",
        "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
        "Connection": "keep-alive",
        "Accept": "*/*",
        "User-Agent": "xiaoqin/8.4 (iPhone; iOS 9.3.2; Scale/3.00)",
        "Accept-Language": "zh-Hans-CN;q=1",
        "Accept-Encoding": "gzip, deflate"
    }
    keycontentjson=[
        {
            "date":1449676800,
            "calories":0,
            "activeValue":225,
            "step":100,
            "pm2d5":0,
            "duration":0,
            "distance":0,
            "report":"[]"
        }
    ]
    print(keycontentjson)
    key = json.dumps(keycontentjson)
    print(key)
    param = {
        "action": "profile",
        "cmd": "updatedaily",
        "pc": "uuid68176b9878a7ac5c9bb655e2a4840214099f7b5a",
        "uid": 77103858,
        "list": key,
        "v": "5.4%20ios",
        "vc": "540%20ios"

    }
    respose = requests.post(url=url, data=param, headers=headers)
    print(respose.text)
get_post1()


import re

import pandas as pd
import time
import requests
import json
def get_post1():
    # url = "http://pl.api.ledongli.cn/xq/io.ashx"
    url = "http://walk.ledongli.cn/rest/dailystats/upload/v3"
    # url = "http://walk.ledongli.cn/rest/dailystats/upload/v3?uid=77103858&pc=uuid68176b9878a7ac5c9bb655e2a4840214099f7b5a&v=8.4%20ios"

    headers = {
        # "Host": "walk.ledongli.cn",
        "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
        "Connection": "keep-alive",
        "Accept": "*/*",
        "User-Agent": "xiaoqin/8.4 (iPhone; iOS 9.3.2; Scale/3.00)",
        "Accept-Language": "zh-Hans-CN;q=1",
        "Accept-Encoding": "gzip, deflate"
    }
    keycontentjson=[
        {
            "date":1449676800,
            "calories":0,
            "activeValue":225,
            "step":100,
            "pm2d5":0,
            "duration":0,
            "distance":0,
            "report":"[]"
        }
    ]
    print(keycontentjson)
    key = json.dumps(keycontentjson)
    print(key)
    param = {
        "action": "profile",
        "cmd": "updatedaily",
        "pc": "uuid68176b9878a7ac5c9bb655e2a4840214099f7b5a",
        "uid": 77103858,
        "list": key,
        "v": "5.4%20ios",
        "vc": "540%20ios"

    }
    respose = requests.post(url=url, data=param, headers=headers)
    print(respose.text)
# get_post1()
# coding: utf-8

# date: 2015年9月29日01:50:37

# usage: edit steps and ledongli's uid(u need to download this app) .That would be ok .Good luck. ^_^

import requests

import sys

import json

import datetime

import time

import random


def isnum(value):
    try:

        temp = int(value)

    except Exception:

        return False

    else:

        return True

    # like 2015-09-25 00:00:00 converts to unix time stamp


def formatDate():
    nowtime = datetime.datetime.now()

    date = time.strftime('%Y-%m-%d')

    strtemp_date = date + ' 00:00:00'

    ledongli_date = time.strptime(strtemp_date, '%Y-%m-%d %H:%M:%S')

    finaldate = time.mktime(
        ledongli_date)  # rusult is 1443456000.0(float type), but still need to format to 1443456000

    finaldate = int(finaldate)

    return finaldate


def main(steps, uid):
    if not isnum(steps):
        print('param error. steps must be an integer.')
        exit()

    url = 'http://pl.api.ledongli.cn/xq/io.ashx'

    fake_headers = {

        'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 5.0.2; MI 2 MIUI/5.7.16)',

        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',

        'Accept-Encoding': 'gzip'

    }

    keycontentjson = [

        {

            "date": formatDate(),

            "calories": 0,

            "activeValue": 108,

            "steps": steps,

            "pm2d5": 0,

            "duration": 0,

            "distance": 0,

            "report": "[]"

        }

    ]

    # key is a str type

    # key must be a json data convert to string

    key = json.dumps(keycontentjson)

    param = {

        'action': 'profile',

        'pc': '865863023705721',

        'cmd': 'updatedaily',

        'uid': uid,

        'list': key

    }

    r = requests.post(url, data=param, headers=fake_headers)

    # return json.loads(r.text)["status"]
    return r


# if __name__ == '__main__':
#     print("Powered By 真红酱\n")
#     uid = input("请输入乐动力ID--->")
#     steps = input("请输入步数--->")
#     print(main(steps,uid))
#     # while main(steps, uid) != "OK":
#     #     pass
#     print("设置完毕:" + str(steps))
#
#     # di 77103858


""" This script simulate a PC wechat client to get wechat sports data """


# Headers: simulate wechat embedded browser
HEADERS = {
    'Connection': 'keep-alive',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)'
                  ' Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501'
                  ' NetType/WIFI WindowsWechat QBCore/3.43.27.400 QQBrowser/9.0.2524.400',
    'Accept-Encoding': 'gzip, deflate'
}

COOKIES = {
    'hwstepranksk': '填入Cookie',
    'pass_ticket': '填入Cookie'
}

REQUEST_URL = 'https://hw.weixin.qq.com/steprank/step/personal'


def get_info(openid):
    """Get data according to openid"""
    params = {"openid": openid}
    data = requests.get(url=REQUEST_URL, params=params, cookies=COOKIES, headers=HEADERS)
    print(data.text)
    exit()
    data.encoding = "utf-8"
    try:
        return parse_code(data.text)
    except LookupError:
        return {"Error": "Cookies could be out of date"}


def parse_code(code):
    """Parse web page source code"""
    match_strings = re.findall(r"window.json = (\S+);", code)
    # json strings are hided in js code
    if len(match_strings) == 0:
        raise LookupError
    else:
        json_string = match_strings[0]
    json_object = json.loads(json_string)
    data_dict = {
        "openid": json_object.get("myopenid"),
        "Today Steps": json_object.get("rankdesc").get("score"),
        "History Steps": json_object.get("rankdetaillist")[0].get("score"),
        "Highest Record": json_object.get("rankdetaillist")[1].get("score")
    }
    return data_dict


# if __name__ == "__main__":
#     print(get_info("o95gOt0QsJ4O4vxBVUzmYeXGuN74"))