需要通过javascript命令读取百度统计API接口,读取数据并存到数据表内,因对JS不熟,需要高手协助
POST地址:https://api.baidu.com/json/tongji/v1/ReportService/getData
POST数据格式如下,需要读取basicinfo表里一行内容,组成post data数据:
{
"header": {
"username": "百度统计用户名",
"password": "******",
"token": "3ae033rrffgghju62340301c8bdd0",
"account_type": 1
},
"body": {
"site_id": "139713455",
"start_date": "20200606",
"end_date": "20200608",
"metrics": "pv_count,visitor_count,ip_count",
"method": "overview/getTimeTrendRpt"
}
}
API返回数据如下,需要对JSON序列化存入到result表
{
"header": {
"desc": "success",
"failures": [],
"oprs": 1,
"succ": 1,
"oprtime": 0,
"quota": 1,
"rquota": 47492,
"status": 0
},
"body": {
"data": [
{
"result": {
"items": [
[
[
"2020/06/06"
],
[
"2020/06/07"
],
[
"2020/06/08"
]
],
[
[
714,
270,
174
],
[
731,
252,
161
],
[
512,
142,
97
]
],
[],
[]
],
"timeSpan": [
"2020/06/06 - 2020/06/08"
],
"fields": [
"simple_date_title",
"pv_count",
"visitor_count",
"ip_count"
]
}
}
]
}
}
|