Python POST 修改某計步APP的資料

2021-08-27 23:39:30 字數 4771 閱讀 4462

使用charles對上傳的資料進行分析

form表單內容分析

展開reqmessagebody的內容(使用json資料格式方便進行檢視)

,

],"listhour": [,],

"reqservicetype": 1

, "sequenceid": "1536550643973"

}

大致判斷步數主要由stepnumber欄位控制,walkdate為計步日期,同時listhour列表中包含了每個計步小時週期內的具體步數,雖然不知道具體的含義,但是已經不影響資料的修改和上傳了

使用requests模擬post表單提交

到現在我們就找到了影響資料步數的資料字段,下面使用python模擬資料互動過程

匯入需要的類和庫檔案

import requests

import urllib

import json

import datetime

import time

import random

通過分析可以得出,真正標識乙個使用者或者裝置的是deviceserial,這個可以通過reqmessagebody看出,同時為了真實偽裝post報文資訊,對headers進行相應設定

url = '**鏈結'

headers =

today = (datetime.datetime.now() - datetime.timedelta(days = 0))

yesterday = (datetime.datetime.now() - datetime.timedelta(days = 1))

str_today = today.strftime("%y

%m%d")

str_yesterday = yesterday.strftime("%y

%m%d")

表頭中設定了user-agent和content-type等關鍵資訊,同時使用datetime函式以及strftime函式獲取格式化為20180910格式的當前日期

為了模擬步數的真實性,使用random.randint函式獲取每個小時時段內的隨機步數

hour6_1number = random.randint(500,1500)

hour6_2number = random.randint(500,1500)

hour7_1number = random.randint(500,1500)

hour7_2number = random.randint(500,1500)

hour8_1number = random.randint(500,1500)

hour8_2number = random.randint(500,1500)

hour10_1number = random.randint(500,1500)

hour10_2number = random.randint(500,1500)

hour12_1number = random.randint(500,1500)

hour12_2number = random.randint(500,1500)

hour13_1number = random.randint(500,1500)

hour13_2number = random.randint(500,1500)

hour18_1number = random.randint(500,1500)

hour18_2number = random.randint(500,1500)

hour19_1number = random.randint(500,1500)

hour19_2number = random.randint(500,1500)

hour20_1number = random.randint(500,1500)

hour20_2number = random.randint(500,1500)

hour21_1number = random.randint(500,1500)

hour21_2number = random.randint(500,1500)

組裝新的message報文資訊

message = ,

],"listhour": [

,,,,0,0".format(step1 = hour10_1number,cal1 = hour10_1number * 70,step2 = hour10_2number,cal2 = hour10_2number * 70,),

"hour11": "228,15960,228,15960,0,0",

#"hour12": "0,0,0,0,0,0",

"hour12":",,,,0,0".format(step1 = hour12_1number,cal1 = hour12_1number * 70,step2 = hour12_2number,cal2 = hour12_2number * 70,),

#"hour13": "0,0,0,0,0,0",

"hour13":",,,,0,0".format(step1 = hour13_1number,cal1 = hour13_1number * 70,step2 = hour13_2number,cal2 = hour13_2number * 70,),

"hour14": "0,0,0,0,0,0",

"hour15": "0,0,0,0,0,0",

"hour16": "0,0,0,0,0,0",

"hour17": "0,0,0,0,0,0",

#"hour18": "0,0,0,0,0,0",

"hour18":",,,,0,0".format(step1 = hour18_1number,cal1 = hour18_1number * 70,step2 = hour18_2number,cal2 = hour18_2number * 70,),

#"hour19": "0,0,0,0,0,0",

"hour19":",,,,0,0".format(step1 = hour19_1number,cal1 = hour19_1number * 70,step2 = hour19_2number,cal2 = hour19_2number * 70,),

#"hour20": "0,0,0,0,0,0",

"hour20":",,,,0,0".format(step1 = hour20_1number,cal1 = hour20_1number * 70,step2 = hour20_2number,cal2 = hour20_2number * 70,),

#"hour21": "0,0,0,0,0,0",

"hour21":",,,,0,0".format(step1 = hour21_1number,cal1 = hour21_1number * 70,step2 = hour21_2number,cal2 = hour21_2number * 70,),

"hour22": "0,0,0,0,0,0",

"hour23": "0,0,0,0,0,0",

"hour24": "0,0,0,0,0,0",

"hour25": "0,0,0,0,0,0",

"hour3": "0,0,0,0,0,0",

"hour4": "0,0,0,0,0,0",

"hour5": "0,0,0,0,0,0",

#"hour6": "508,35560,508,35560,0,0",

"hour6":",,,,0,0".format(step1 = hour6_1number,cal1 = hour6_1number * 70,step2 = hour6_2number,cal2 = hour6_2number * 70,),

#"hour7": "184,12880,184,12880,0,0",

"hour7":",,,,0,0".format(step1 = hour7_1number,cal1 = hour7_1number * 70,step2 = hour7_2number,cal2 = hour7_2number * 70,),

#"hour8": "659,46130,659,46130,0,0",

"hour8":",,,,0,0".format(step1 = hour8_1number,cal1 = hour8_1number * 70,step2 = hour8_2number,cal2 = hour8_2number * 70,),

"hour9": "0,0,0,0,0,0",

"walkdate": str_today,

#"walkdate": "20180910"

},],

"reqservicetype": 1,

"sequenceid": "1536550643973"

}

使用requests函式提交表單資訊並列印返回資訊

req_message = ],"listhour":,"reqservicetype":1,"sequenceid":"1536561269248"}',

'reqmessagebody' : json.dumps(message),

'commond' : 'uploaddata'

}r = requests.post(url,headers = headers,data = req_message)

r.raise_for_status()

print(r.text)

time.sleep(10)

csharp 複製DataTable修改某列的值

塗聚文 2012 04 14 static datatable getdectable datatable table datatable tablecopy table.copy datatable tabledec new datatable tabledec table.copy 得到列的名稱...

關於簡單的js計步功能

複製 1 計步演算法 關於詳細的計步演算法網上能找到很多的資源,這裡只是簡單的做了個實驗性質的介紹,並不是很準確,另外也沒有測試詳細的相容性。功能 通過js獲取手機上的感測器資訊進行計算獲得簡單的步數統計。用到了加速度感測器模組。通過對手機的加速度感測器模組記錄的值進行分析來獲取使用者的步數。計步演...

基於智慧型手機的加速計進行計步實現。

最近在研究如何使用 iphone手機進行計步,網上找了些資料,基本上是基於加速計原理。至於什麼是加速計,加速計的使用原理大家就到google 上了,這裡不講這部份。在研究中,根據自己搜到的資料,有使用差分法,離散,快速傅利葉變換來進行過濾提取,但是,由於我畢業多年了,這些大學裡的演算法,我也忘得七七...