imp.py 1.35 KB
Newer Older
liuxiaoxing committed
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
import random
import requests
import socket
import struct
import time
import datetime




URL = 'https://imp.control.kochava.com/track/impression?testparam=TestValue&campaign_id=kolukatest1223-6x22b314c00b175e&' \
      'network_id=280&event=view&ip_address=$USER_IP&device_ua=$UA&impression_id=$IMP_ID&creative_size=$AD_SLOT'



s = 0
w = 0


for _ in range(1):
    # print("开始时间"+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
    #随机生成12为数组
    i = ''.join(str(random.choice(range(10))) for _ in range(12))
    # i = '1234567811'
    #随机生成ip
    ip = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
    # ip = '192.168.2.86'
    try:

        parms = {
            'idfg': i,
            'device_id': i,
            'ip_address': ip,
            'impression_id': i
            }
        #timeout可以超时四秒
        p = requests.get(url=URL,params=parms,timeout=30)
        # time.sleep(10)
        # allEvent().install_android(i,ip,appkey)
        print('imei:',i)
        print("ip:",ip)
        print('success:',s)
        print(p.text)
        # print(p.status_code)
        #print('androidid:',a)
        s=s+1
    except Exception as err:
        print(err)
        print('wrong:', w)
        print('imei:', i)
        print("ip:",ip)
        # print(p.status_code)
        #print('androidid', a)
        w=w+1