ios_script.py 11.5 KB
import requests
import json
import time
import random
import threading

from jiami.pdj import encryptorForAES

headers = {'Content-Type': 'application/json'}


# URL = 'https://log.analysis.com/receive/analysis/'

URL = 'http://119.3.252.134/receive/analysis/'

URLbatch = 'http://119.3.252.134/receive/'





#时间戳
current_time_13 = int(round(time.time() * 1000))
#时间和日期
when = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
# when = '2019-11-10 10:45:33'
#日期
ds = time.strftime('%Y-%m-%d', time.localtime(time.time()))
# ds = '2019-11-10'
#设备品牌
manufacturer = '苹果'
#设备系统
ryos = 'ios'
#设备类型
rydevicetype = 'iphone'
#网络类型
network = 'wifi'
#分辨率
resolution = '111*670'
#运行商
op = '中国移动'
channelid = '111'
#版本
app_version = '11.05.01'
model = 'iPhone 4'
event = 'event_1212'
page = 'page_1212'
session = '312211'
class allEvent:
    # 激活
    def installUpload(self, i,IP,appkey,JDClass):
        s = json.dumps({
            "appid": appkey,
            "ds": ds,
            "what": "install",
            # "when": when,
            "where": "install",
            "who": i,
            "context": {
                "_frequency": "0.000",
                "_manufacturer": manufacturer,
                # "_city": "北京",
                "_lats": "1",
                "_network_type": network,
                # "_country": "中国",
                "_timestamp": current_time_13,
                "_device_gps": "unknown",
                "_modify": "0",
                "_ipv6": "fe80::810:c0fd:6a98:e3e2",
                "_tz": "+8",
                "_ry_ts": "1572406560870",
                "_pkgname": "com.reyun.sdktrackingtest",
                "_audio_volume": "0.562",
                "_app_version": app_version,
                "_jbk": "0",
                # "_ry_origin_when": "2019-10-30 11:36:00",
                "_model": model,
                "_idfv": "0B7B677B-47C6-4615-B938-983EB8C09B28",
                "_ip": IP,
                "_lib": "iOS",
                "_mac": "02:00:00:00:00:00",
                "_ryos": ryos,
                "_create_timestamp": current_time_13,
                "_idfa": i,
                "_ryosversion": "13.2",
                "_resolution": resolution,
                # "_region": "北京",
                "_lib_version": "a1.0.0",
                "_deviceid": i,
                "_rydevicetype": "iPhone",
                "_carrier": op,
                "_screen_brightness": "0.698",
                "_channelid": channelid
            },
        })

        s = encryptorForAES(s,JDClass)
        # print(s)
        # print(URL+'install')

        p = requests.post(url=URL+'install', data=s, headers=headers, timeout=10)
        print("激活:"+p.text)
        # print(ds)

    # 启动
    def startupUpload(self, i,IP,appkey,JDClass):
        s = json.dumps({
            "appid": appkey,
            "context": {
                "_frequency": "0.000",
                "_manufacturer": manufacturer,
                # "_city": "北京",
                "_lats": "1",
                "_network_type": network,
                # "_country": "中国",
                "_timestamp": "1572406560809.306",
                "_device_gps": "unknown",
                "_modify": "0",
                "_ipv6": "fe80::810:c0fd:6a98:e3e2",
                "_tz": "+8",
                "_ry_ts": "1572406560870",
                "_pkgname": "com.reyun.sdktrackingtest",
                "_audio_volume": "0.562",
                "_app_version": app_version,
                "_jbk": "0",
                # "_ry_origin_when": "2019-10-30 11:36:00",
                "_model": model,
                "_idfv": "0B7B677B-47C6-4615-B938-983EB8C09B28",
                "_ip": IP,
                "_lib": "iOS",
                "_mac": "02:00:00:00:00:00",
                "_ryos": ryos,
                # "_create_timestamp": "1572406560809.306",
                "_idfa": i,
                "_ryosversion": "13.2",
                "_resolution": resolution,
                # "_region": "北京",
                "_lib_version": "a1.0.0",
                "_deviceid": i,
                "_rydevicetype": "iPhone",
                "_carrier": op,
                "_screen_brightness": "0.698",
                "_channelid": channelid
            },
            "ds": ds,
            "what": "startup",
            "when": when,
            "where": "startup",
            "who": i
        })

        s = encryptorForAES(s,JDClass)
        p = requests.post(url=URL+'startup', data=s, headers=headers, timeout=10)
        print("启动:"+p.text)
        # print(p.url)
    # 事件
    def eventUpload(self, i, IP, appkey,interface_type,JDClass):
        s =json.dumps({
            "appid": appkey,
            "ds": ds,
            "what": event,
            "when": when,
            "where": "event",
            "who": i,
            "context": {
                "_ry_origin_when": when,
                "_idfv": "0B7B677B-47C6-4615-B938-983EB8C09B28",
                # "_city": "unknown",
                "_ip": IP,
                "_lib": "iOS",
                "_session": "6",
                "_interface_type": interface_type,
                "_country": "unknown",
                "_timestamp": current_time_13,
                "_create_timestamp": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
                "_idfa": i,
                # "_region": "unknown",
                "_lib_version": "a1.0.0",
                "_deviceid": i,
                "_model": model,
                "_tz": "+8",
                "_channelid": channelid,
                "_ry_ts": "1572335394441",
                "_app_version": app_version,
                "_batch_type": "eventbatch"

            },

        })
        s = encryptorForAES(s,JDClass)
        p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=10)
        print("事件:" + p.text)
        # print(p.url)
    # page
    def pageUpload(self, i, IP, appkey,interface_type,JDClass):
        s = json.dumps({
	        "appid": appkey,
            "ds": ds,
            "what": page,
            "when": when,
            "where": "page",
            "who": i,
	        "context": {
                "_idfv": i,
                # "_city": "unknown",
                "_ip":IP,
                "_lib": "iOS",
                # "_batch_type": "pagebatch",
                "_session": session,
                "_interface_type": interface_type,
                "_country": "unknown",
                "_timestamp": current_time_13,
                "_create_timestamp": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
                "_idfa": i,
                # "_region": "unknown",
                "_lib_version": "a1.0.0",
                "_deviceid": i,
                "_model": model,
                "_tz": "+8",
                "_channelid": channelid,
                "_ry_ts": "1572342341972",
                "_app_version": app_version
            },
        })
        s = encryptorForAES(s,JDClass)
        p = requests.post(url=URL + 'page', data=s, headers=headers, timeout=10)
        print("page:" + p.text)
        # print(p.url)


    # 退出
    def exitUpload(self, i, IP, appkey,JDClass):
        s = json.dumps({
	        "appid": appkey,
            "ds": ds,
            "what": "exit",
            "when": when,
            "who": i,
	        "context": {
                "_ry_origin_when": when,
                "_triger": "terminate",
                "_idfv": i,
                # "_city": "unknown",
                "_ip": IP,
                "_exit_page": page,
                "_lib": "iOS",
                "_model": model,
                "_session": session,
                "_country": "unknown",
                "_timestamp": current_time_13,
                "_create_timestamp": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
                "_idfa": i,
                # "_region": "unknown",
                "_lib_version": "a1.0.0",
                "_deviceid": i,
                "_tz": "+8",
                "_channelid": channelid,
                "_ry_ts": "1572343547238",
                "_app_version": app_version
	        },

        })
        s = encryptorForAES(s, JDClass)
        p = requests.post(url=URL + 'exit', data=s, headers=headers, timeout=10)
        print("退出:" + p.text)
        # print(p.url)
    # 批量上传数据接口
    def batchUpload(self, i, IP, appkey,JDClass):
        s = json.dumps(
            {
                "from": "analysis",
                "data": [
                    {
                        "appid": appkey,
                        "when": when,
                        "what": "page1",
                        "who": "unknown",
                        "context": {
                            "_manufacturer": "苹果",
                            "_carrier": op,
                            "_lats": "1",
                            "_jbk": "1",
                            "_app_version": app_version,
                            "_timestamp": current_time_13,
                            "_create_timestamp": current_time_13,
                            "_rydevicetype": "iPhone",
                            "_deviceid": i,
                            "_tz": "+8",
                            "_resolution": resolution,
                            "_pkgname": "com.reyun.testapp",
                            "_mac": "80:E6:50:12:4C:DE",
                            "_network_type": network,
                            "_istf": "8",
                            "_idfv": "27CCEE6E-5ED1-47EC-B486-81F9129C05D3",
                            "_ryosversion": "11.2",
                            "_model": model,
                            "_lib_version": "2.0.0",
                            "_ryos": ryos,
                            "_idfa": i,
                            "_batch_type":"pagebatch"
                        },
                    },
                    {
                        "appid": appkey,
                        "when": when,
                        "what": "dsadxas",
                        "who": "unknown",
                        "context": {
                            "_manufacturer": "苹果",
                            "_carrier": op,
                            "_lats": "1",
                            "_jbk": "1",
                            "_app_version": app_version,
                            "_timestamp": current_time_13,
                            "_create_timestamp": current_time_13,
                            "_rydevicetype": "iPhone",
                            "_deviceid": i,
                            "_tz": "+8",
                            "_resolution": resolution,
                            "_pkgname": "com.reyun.testapp",
                            "_mac": "80:E6:50:12:4C:DE",
                            "_network_type": network,
                            "_istf": "8",
                            "_idfv": "27CCEE6E-5ED1-47EC-B486-81F9129C05D3",
                            "_ryosversion": "11.2",
                            "_model": model,
                            "_lib_version": "2.0.0",
                            "_ryos": ryos,
                            "_idfa": i,
                            "_batch_type": "pagebatch"
                        },
                    }
                ]
            }

        )
        s = encryptorForAES(s, JDClass)
        p = requests.post(url=URLbatch + 'batch', data=s, headers=headers, timeout=10)
        print("批量:" + p.text)
        print(p.url)