首页 » Python » python调用百度api各个计划的展现消费点击并格式化打印出来

python调用百度api各个计划的展现消费点击并格式化打印出来

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests,sys,json,time,datetime,re

today=datetime.date.today()
oneday=datetime.timedelta(days=1)
yesterday=today-oneday

url = "https://api.baidu.com/json/sms/service/ReportService/getRealTimeData"
data = {"header":{
"username":"",
"password":"",
"token":""
},
"body":{
"realTimeRequestType":{
"reportType":10,
"levelOfDetails":3,
"startDate":str(yesterday),
"endDate":str(yesterday),
"performanceData":["impression","click","cost"],
"device":2

}
}
}
response = requests.post(url,json.dumps(data))
#print(response.text)
for zhanxian,dianji,xiaofei,jihuaming in re.findall(r'kpis"\:\["(.*?)"\,"(.*?)"\,"(.*?)"\]\,"name"\:\[".*?"\,"(.*?)"\]',response.text):
    print(zhanxian,dianji,xiaofei,jihuaming)

原文链接:python调用百度api各个计划的展现消费点击并格式化打印出来,转载请注明来源!

0